Sometimes, setting up HTTP/HTTPS GCP Firewall rule and Nginx reverse proxy to point to the Docker container port mapped as 0.0.0.0:3000
could be not enough, even though running curl 0.0.0.0:3000
on the same machine works as intended. So, here’s the catch.
Prerequisites
- CentOS 7
- Docker
- Nginx
Solution
Apparently, the good old SELinux was enabled by default. How could have I missed that.
Step 1. Enable the SELinux’s httpd_can_network_connect
flag.
setsebool -P httpd_can_network_connect on
Step 2. Verify.
getsebool -a | grep httpd_can_network_connect
That should have done it.
quick “dirty” fix
But, if you want a quick, dirty fix, disable SELinux completely even though I would not recommend it. Run:
setenforce 0
Also, there is another way to do so. Update the SELINUX
value to disabled.
Step 1. Open /etc/selinux/config
and update the following line:
SELINUX=disabled
Step 2. Save the file and reboot the instance.
Conclusion
If you have any other great solutions on this topic, or even issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.