Open sreayunw opened 3 years ago
This is happen because you are using bridge
network. Please take a look this: "Use host networking" on docker's documentation. Note that port mapping will be ignored - It means gitlab will be published on your host's 80 port, ssh port will be published on your host's 22 port. Others are the same
@kkimurak Thank you for your reply!But I don't think this has anything to do with bridge network mode,because I saw earlier in the documentation:https://github.com/sameersbn/docker-gitlab#available-configuration-parameters about parameter of "NGINX_REAL_IP_RECURSIVE", and I wonder if it has something to do with this parameter。
and I need to use bridge network mode to expose 10080 and 10022 ports。So there's another way?
I refer to the following file https://github.com/sameersbn/docker-gitlab/blob/master/docker-compose.yml for operations, and I happen to need to expose ports 10080 and 10022
Docker network does not set any headers that nginx can receive. Containers cannot get real remote IP address. This is a problem of docker itself as far as I know. Please refer https://github.com/docker/roadmap/issues/157 .
The one of solution is to put everything in network_mode: host
as far as I have researched.
Running reverse proxy is another idea. Then set NGINX_REA_IP_RECURSIVE
and NGINX_REAL_IP_TRUSTED_ADDRESSES
correctly. I saw some people use jwilder/nginx-proxy
(it seems to moved its namespace to nginx-proxy/nginx-proxy
) with host mode network but I have never tested.
Whether I set NGINX_REAL_IP_RECURSIVE to off or on, remote_IP in the gitlab production_json.log file shows the remote_IP of the Docker bridge
docker-compose.yml is :
When I use git clone, I see that remote_ip in production_json.log is 172.24.0.1
can any one help me? thanks!