if you run something (e.g. nginx) in a Docker container and publish one of the exposed ports to the outside world (like docker run -p 80:80 nginx
) then Docker will
- expose the port to the public
- set up iptables so that if something connects to the container through the Docker network bridge (NAT) then nginx will still know the proper source IP
- ! open the firewall to that port completely
I don't want to allow anyone to connect to the published port, but Docker messes that up. So I relaunched the Docker daemon with --iptables=false
that allows me to manage the firewall myself. However, nginx now only sees the bridge (172.18.0.1) as the source address.
How can I keep control over the firewall and still forward the source IP address to the container?