File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11events {}
22
33http {
4-
5- upstream web {
6- server web:5000;
7- }
4+ # Docker's embedded DNS — see nginx.prod.conf for the full rationale.
5+ # In dev this matters less (no Watchtower) but keeps both configs in
6+ # sync and lets `docker compose restart web` work without having to
7+ # restart nginx too.
8+ resolver 127.0.0.11 ipv6=off valid=10s;
89
910 server {
1011
1112 listen 80;
1213
1314 client_max_body_size 10000M;
1415
16+ set $web_upstream http://web:5000;
17+
1518 location / {
1619
1720 # Set proxy headers
18- proxy_pass http://web ;
21+ proxy_pass $web_upstream ;
1922 proxy_set_header Host $http_host;
2023 proxy_set_header X-Real-IP $remote_addr;
2124 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Original file line number Diff line number Diff line change 11events {}
22
33http {
4-
5- upstream web {
6- server web:5000;
7- }
8-
4+ # Docker's embedded DNS. We point nginx at it explicitly so that
5+ # upstream hostnames can be re-resolved at *request* time, not just
6+ # when the config is loaded. Without this, a rolling Watchtower update
7+ # replaces web_app_container with a fresh IP and nginx keeps hitting
8+ # the old one until someone restarts it.
9+ #
10+ # `ipv6=off` avoids a gotcha on networks that advertise an IPv6 record
11+ # without actually having upstream IPv6 connectivity.
12+ # `valid=10s` caps the DNS cache so the next container takeover is
13+ # picked up within that window.
14+ resolver 127.0.0.11 ipv6=off valid=10s;
15+
16+ # Note: an `upstream {}` block CANNOT use `resolver` — the name is
17+ # resolved once at config-parse time and cached forever. Storing the
18+ # URL in a variable and interpolating it in `proxy_pass` forces nginx
19+ # down the dynamic-resolution path instead.
920 server {
10-
21+
1122 listen 80;
1223
1324 client_max_body_size 10000M;
1425
26+ set $web_upstream http://web:5000;
27+
1528 location / {
1629
1730 # Set proxy headers
18- proxy_pass http://web ;
31+ proxy_pass $web_upstream ;
1932 proxy_set_header Host $http_host;
2033 proxy_set_header X-Real-IP $remote_addr;
2134 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
You can’t perform that action at this time.
0 commit comments