Welcome! Log In Create A New Profile


using reverse proxy nginx in a docker container

Posted by reubendevries 
using reverse proxy nginx in a docker container
July 14, 2021 09:54PM
So trying to setting nginx as a reverse proxy using docker - I have three node js containers (one frontend and two backend services) the frontend service calls the two backend services. So I want nginx to redirect to the frontend (which is web application), but every time I try to send something I get a 502 bad gateway error. When I directly exec into the docker containers I can ping the other containers via dns_hostname or ip address (which I grab from docker inspect). I've attached an edited version of both my docker-compose.yaml and my nginx.conf (only renamed a few things to make them look a bit more generic etc.)

I've almost done everything to rule out a networking issue, as I can ping both the ip address and the frontend docker hostname from the inside of the nginx container (using docker exec -it nginx-proxy sh) is anyone has any suggestions on what to try next or they can see clearly if I'm doing something wrong it would be much appreciated.
open | download - nginx.conf (1.1 KB)
open | download - docker-compose.yaml (1.7 KB)
Re: using reverse proxy nginx in a docker container
July 15, 2021 05:45PM
Issue solved - The issue WAS NOT NGINX. The issue was a former developer trying to be helpful that ended up kicking our ass in the long run. They created a redirect in their code that if someone tried to use the HTTP protocol it would automatically redirect to HTTPS, once we commented this pesky couple lines of code out and rebuilt the container, surprise, surprise... NGINX did as it was told. Lesson learned: Get NGINX to do your redirecting; not your code.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 94
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready