I have an ubuntu server machine in which I have deployed a docker container running some app. For some tests I needed, I added an iptables entry in the ubuntu machine - to route traffic coming on port 443 to port 8443. Did it as follows:
sudo iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-ports 8443
Now, I see that the app I am running inside the docker container is facing some bigger issues. Ex: the app itself calls some other external service over ssl. That is now failing. Gives me an error: Connect to ***.abc.com:443 timed out. I know taht this external service is working from other similarly configured machines.
I see a similar issue with other external services that my app is trying to reach over ssl.
Looks like I botched up something with the above iptables command. I therefore looked up a bit and tried the following:
sudo iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-ports 443
sudo iptables -D PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-ports 8443
I thought the first line would ensure all traffic to port 443 does go to port 443 indeed and the 2nd line would undo the iptables entry I added earlier.
I also tried restarting the iptables service itself. (Since I did not save the iptables entry)
However, I still see the above mentioned issue. I dont understand why it is impacting traffic from within my docker container to the outside world.
Any inputs on what the problem is.
TIA - Om.