Answer the question
In order to leave comments, you need to log in
How to get the real ip of the user inside the docker container?
I'm building a docker image based on "ubuntu:16.04". I raise nginx in it with the simplest configuration:
server {
listen 80;
location / {
return 200 'Remote addr = ${remote_addr}, X-Forwarded-For = ${proxy_add_x_forwarded_for}';
}
}
docker run --name=mycontainer -p 80:80 -d myimage
"Remote addr = 172.17.0.1, X-Forwarded-For = 172.17.0.1"
Answer the question
In order to leave comments, you need to log in
When asked from where? It looks like you're on the internal network and making requests, otherwise X-Forwarded-For would be different. Make a request to the public IP of the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question