Docker Nginx Reverse Proxy to Node, Step by Step
Running Nginx in Docker with a reverse proxy to a local Node process is the smallest deployable unit that resembles a real production topology. Understanding the port-mapping and volume-mount mechanics here prevents the most common Docker networking mistakes when moving from localhost-only development to containerized services.
A Node.js Express app listens on port 1314. Instead of exposing that port directly, an Nginx container listens on port 80 and forwards traffic to the Node service via proxy_pass. Docker's port mapping (-p 80:80) routes host traffic into the container, and a volume mount (-v) injects the nginx.conf that defines the forwarding rule. The Node process runs on the host and is reachable from the container through host.docker.internal.
The result is a clean separation: Nginx handles request entry and routing, Node handles business logic. Users never see the backend port, and the setup mirrors a minimal production deployment pattern where a reverse proxy sits in front of application services.
Common Docker lifecycle commands — ps, stop, rm, rmi — round out the workflow, making the whole stack manageable from the terminal.
The tutorial uses host.docker.internal to let a container reach a service running directly on the host, which is a pragmatic bridge for developers not yet ready to containerize every service but still wanting to practice reverse-proxy patterns.
Mounting a single config file instead of baking it into a custom image keeps the setup trivial to iterate on — change the file, restart the container, and the new routing takes effect immediately.