mirror of
https://github.com/Such-Software/xmrcheckout.git
synced 2026-10-17 05:51:34 +02:00
Mirror of wowcheckout e0c349a. Same bug would bite xmrcheckout after any api container rebuild — nginx caches IP at startup and never re-resolves, so a rebuild that gives the api container a new IP leaves nginx 502'ing until manually restarted. Use 'resolver 127.0.0.11 valid=10s' + variable-based proxy_pass so nginx re-resolves every ~10s via Docker's internal DNS.
58 lines
1.7 KiB
Plaintext
58 lines
1.7 KiB
Plaintext
limit_req_zone $binary_remote_addr zone=global_rate_limit:10m rate=50r/s;
|
|
|
|
# Docker's embedded DNS (127.0.0.11) lets nginx re-resolve upstream service
|
|
# hostnames. Without `resolver` + a variable-based proxy_pass, nginx resolves
|
|
# `api` / `ui` to an IP once at startup and caches it forever — if the api
|
|
# container is rebuilt and Docker gives it a new IP, nginx keeps hitting the
|
|
# old one and every request returns 502 Bad Gateway until nginx is manually
|
|
# restarted. `valid=10s` bounds the stale window to ~10 seconds.
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name xmrcheckout.such.software localhost;
|
|
|
|
limit_req zone=global_rate_limit burst=200 nodelay;
|
|
|
|
if ($request_uri ~* "//+") {
|
|
return 308 $scheme://$host$uri$is_args$args;
|
|
}
|
|
|
|
location /api/ {
|
|
set $api_upstream "api";
|
|
proxy_pass http://$api_upstream:8000/api/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /api {
|
|
return 301 /api/;
|
|
}
|
|
|
|
location = /openapi.json {
|
|
set $api_upstream "api";
|
|
proxy_pass http://$api_upstream:8000/openapi.json;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /qr/ {
|
|
alias /qr/;
|
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location / {
|
|
set $ui_upstream "ui";
|
|
proxy_pass http://$ui_upstream:3000/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|