Issues Connecting to Container with Nginx Reverse Proxy
Asked by
CuriousCoder42
I'm trying to update my Nginx reverse proxy configurations to point to my Docker containers using their names and ports. I have one setup that's working fine, but another one isn't. Here's the working example: when I go to bookstack.domain.com, it directs to http://bookstack:8080 and loads the log-in screen perfectly. However, when I try to visit bentopdf.domain.com, I get a "502 Bad Gateway" error instead. Both 'bookstack' and 'bentopdf' are container names. What could I be missing?
Answers
Check if the bentopdf container is on the same virtual network as your Nginx container. If it's not, Nginx won't be able to reach it. Once I associated bentopdf with the right network, my issue was resolved. It was just on the default bridge before, but after moving it, everything worked smoothly!
Reply to this answer
Is bentopdf in the same network as Nginx? If they're not on the same Docker network, Nginx won't be able to find bentopdf. That could definitely lead to the errors you're seeing.
Reply to this answer
Running both containers on port 8080 internally is totally fine. The reverse proxy handles the incoming traffic and you donโt always need to expose those ports externally unless required. Just ensure that your Nginx config is set up correctly.
Reply to this answer
It's hard to pinpoint the issue without more details. What services are running in the bentopdf container? Is there something actively listening on port 8080? Have you checked the logs for any clues?
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions