About this project
nginx-proxy is a containerized reverse proxy solution for Docker environments. It runs nginx together with docker-gen, a companion tool that watches the Docker daemon and generates nginx reverse proxy configuration files based on running containers, then reloads nginx when containers are started or stopped.
Usage centers on two steps. First, run the nginx-proxy container, publishing port 80 and mounting the Docker socket read-only:
docker run --detach --name nginx-proxy --publish 80:80 --volume /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy:1.11
Second, start any application container with the environment variable VIRTUAL_HOST set to the desired hostname, for example VIRTUAL_HOST=foo.bar.com. Once DNS for that hostname resolves to the Docker host, requests are routed to the matching container.
Requirements for proxied containers: they must expose the port to be proxied (via EXPOSE in the Dockerfile or the --expose flag), and they must share at least one Docker network with the nginx-proxy container. Port numbers cannot be supplied inside VIRTUAL_HOST; the documentation covers virtual ports and custom external HTTP/HTTPS ports for those cases.
Image variants include a Debian-based image built on nginx:mainline, an Alpine-based image with the -alpine suffix, and a -dockergen image intended for separate-container setups alongside the official nginx image. The README advises against using the latest, alpine, or dockergen tags in production because they track the main branch and may introduce breaking changes; pinning an explicit version is recommended.
The project is officially maintained by ZeroSSL. Additional documentation is available in the repository's docs section, and the README links to a background article explaining the motivation for automated nginx reverse proxying in Docker.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.