@@ -93,6 +93,30 @@ id: 6c4d42c1c0f03, name: stack-3285f74574bd152c-nginx-proxy-1, ports: 0.0.0.0:80
9393id: 700202db6e6ab, name: stack-3285f74574bd152c-frontend-1, ports: 0.0.0.0:56454->3000/tcp
9494```
9595
96+ ## How Docker Ingress Works
97+
98+ The stack tool does not write nginx configuration files directly. Instead, it relies on
99+ [ nginxproxy/nginx-proxy] ( https://github.com/nginx-proxy/nginx-proxy ) , which automatically generates and reloads
100+ nginx configuration by discovering environment variables on containers via the Docker API.
101+
102+ The process has three stages:
103+
104+ 1 . ** Annotations to spec** : During ` stack init ` , port annotations in ` composefile.yml ` (e.g.,
105+ ` "3000" # @stack http-proxy / ` ) are parsed and written into an ` http-proxy ` section in the output spec file,
106+ mapping paths to backend services and ports.
107+
108+ 2 . ** Spec to environment variables** : During ` stack deploy ` , the tool reads the ` http-proxy ` spec and injects
109+ environment variables into each matching service's Docker Compose definition:
110+ - ` VIRTUAL_HOST_MULTIPORTS ` — a JSON object describing the hostname, path routing rules, and destination ports.
111+ For non-root paths, a regex rule is generated that strips the prefix so the backend sees requests at ` / ` .
112+ - ` LETSENCRYPT_HOST ` — set to the hostname (unless it is ` localhost ` ), triggering automatic SSL certificate
113+ provisioning via the companion letsencrypt container in the ingress stack.
114+
115+ 3 . ** nginx-proxy generates nginx config** : The ` nginx-proxy ` container in the
116+ [ docker-ingress-stack] ( https://github.com/bozemanpass/docker-ingress-stack ) watches the Docker socket for
117+ container events. When it sees containers with ` VIRTUAL_HOST_MULTIPORTS ` environment variables, it generates
118+ the appropriate nginx configuration and reloads nginx automatically.
119+
96120## Combining Stacks
97121
98122It is often useful to create "super stacks" by combining and deploying multiple stacks together as a single unit.
0 commit comments