Docker nextcloud setup (nginx + nginx + fpm) - ip forwarding does not work

yesterday I installed nextcloud 17, based on docker with a nginx as reverse
proxy and nginx as web server which deals with the nextcloud fpm image.

I used for the nginx the official configuration, which is described in the
documentation. The nginx reverse proxy pass all connections forward to the
nextcloud nginx. But when I look into the logs, the nginx does not forward the
real ip, although I have configured the proxy_set_header variables.

  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

That’s a big problem, because users which try to login with wrong credentials
trigger the mechanism to block the next login. That leads to the fact that every
user which use the docker brige ip to login into the nextcloud get a warning,
that the IP has been blocked for 30 seconds or more.

Has anyone an idea, how to configure the nginx proxy and nginx nextcloud correctly?
I have uploads a sample setup as tar archive:


Situation might be different for you because of the fpm image. I would probably start with the trusted_proxies option. This could be enough already.