Real IP in Docker behind nginx reverse proxy

I am running NC15 in docker behind a nginx reverse proxy. The problem I am facing is that the NC logs do not show the real IP address of users. Instead it shows the docker ip:

app_1  | 172.25.0.1 - root [25/Dec/2018:12:17:37 +0000] "PROPFIND /remote.php/dav/files/root/ HTTP/1.0" 207 1118 "-" "Mozilla/5.0 (Linux) mirall/2.5.1git (Nextcloud)"

The interesting part of my nginx reverse proxy config looks like:

    location / {
        proxy_pass http://localhost:8090;
        proxy_set_header        Host                 $host;
        proxy_set_header        X-Real-IP            $remote_addr;
        proxy_set_header        X-Forwarded-For      $proxy_add_x_forwarded_for;
        proxy_set_header        X-Remote-Port        $remote_port;
        proxy_set_header        X-Forwarded-Proto    $scheme;
        proxy_redirect          off;

    }

What is wrong with these settings?

Maybe related? https://github.com/nextcloud/docker/issues/294

Solved via doing this inside the official NC15 docker image:

1 Like