Answer the question
In order to leave comments, you need to log in
In the logs of Nginx running in a Docker container, IP gateway is displayed. Is it possible to force to display the real IP of the client?
Hello.
I have a Windows-10 machine running Docker. The container is running Nginx.
The Nginx logs contain something like this:
172.17.0.1 "GET / HTTP/1.1" 200 20/Jan/2021:10:30:19 +0200 Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0 "-"
[
{
"Name": "bridge",
"Id": "5851bc62c8ca9969ca6dec48574d7bcb9e503dee5f7130e31fb83985b142e6c6",
"Created": "2021-01-19T20:13:53.9892753Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"d2da953e9a9e8bb7b6e835255c3a7b5fc3b1018fd5c3d2cedd31de4c9d1c15dd": {
"Name": "frontend",
"EndpointID": "2cba04a0774fec12a49fd78cf1f41c543b15d625135fe4a0f4481dc093bd8b9f",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Answer the question
In order to leave comments, you need to log in
Add to nginx config:
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question