Use Docker embedded DNS (127.0.0.11) with 30s TTL and variable-based proxy_pass so nginx re-resolves the API container IP after recreates instead of caching the startup IP forever. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
825 B
Nginx Configuration File
30 lines
825 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Use Docker's embedded DNS with 30s TTL so upstream IPs refresh
|
|
# after container recreates
|
|
resolver 127.0.0.11 valid=30s ipv6=off;
|
|
|
|
# SPA fallback
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# API proxy — variable forces nginx to re-resolve on each request
|
|
location /api/ {
|
|
set $backend http://chrysopedia-api:8000;
|
|
proxy_pass $backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /health {
|
|
set $backend http://chrysopedia-api:8000;
|
|
proxy_pass $backend;
|
|
}
|
|
}
|