Skip to content

Commit 68750e9

Browse files
committed
Merge branch 'develop' into main
2 parents f755864 + 3d4e782 commit 68750e9

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

docker/nginx/nginx.dev.conf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
events {}
22

33
http {
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;

docker/nginx/nginx.prod.conf

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
events {}
22

33
http {
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;

0 commit comments

Comments
 (0)