That's exactly what nginx-proxy does: it listens to port 80 (the standard HTTP port) and forwards incoming requests to the appropriate container. This is often known as a reverse proxy, and takes advantage of Docker's VIRTUAL_HOST variable.Can I replicate a virtual host environment with Docker containers?
I was playing with Docker last week and decided to replicate a virtual host environment where different domains should point to different containers running in the host machine. The same way we can easily do with Apache or Nginx.How does Nginx-proxy work to host multiple websites?
How nginx-proxy works to host multiple websites As you can see from the code in both options, the container listens on port 80 and exposes the same port inside of the container. That allows all incoming traffic to flow though nginx. You might be wondering what the /var/run/docker.sock:/tmp/docker.sock line accomplishes.How do I host multiple websites from a single Docker container?
But, containerizing software leads to another problem that confuses many: How do I host multiple websites, each in a separate Docker container, from one VPS? Fortunately, with a little bit of foresight and configuring, you can use Docker and Nginx to host multiple websites from a single VPS.