I have a docker setup which disabled its default behaviour of tampering with iptables
. So all works perfectly fine that I can allow or block specific port to outside world by specifying rule on ufw
. Until I found the problem of not able to access the real IP of client accessing the website. All I see is 172.0.0.1 inside my container which is the IP docker0
network.
I found a solution that asked me to add the below to my iptables
iptables -t nat -A PREROUTING ! -i docker0 -p tcp --dport 80 -j DNAT --to-destination 172.17.0.7:80
where 172.17.0.7
is the IP of proxy container. Now the problem is this IP tend to change if it happen to reboot and then my rule will no longer be valid.
Is there any elegant way of solving this issue without going in the route of assigning static IP to containers if at all it is possible.
Let me know if you need to see any more details of my setup. I am happy to post them.