Issues Connecting to Container with Nginx Reverse Proxy

December 16, 2025 4 answers
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

DockerDude89
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
NetworkNinja
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
ProxyMaster3000
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
NerdyNetWorker
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