Gitlab Docker behind Apache reverse proxy Wrong client IP displayed

Hello!

I’ve got Gitlab running in a Docker container behind an Apache2 reverse proxy. The connection from the client to the proxy server is over SSL and the connection from the proxy server to the Gitlab container is over HTTP.

The problem I’m facing is even with ProxyPreserveHost enabled in the Apache config the sign in IP for each user is still set as the Docker gateway’s IP.

I read https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#change-the-default-proxy-headers however it doesn’t actually say what headers I need to set for my specific setup.

It seems that in order to fix this and have the client IP displayed correctly you simply stick the lines below into the gitlab.rb file. I’m not too sure why this works.

nginx['proxy_set_headers'] = {
  "X-Real-IP" => nil
}