mirror of
https://github.com/Such-Software/wowcheckout.git
synced 2026-10-17 05:51:45 +02:00
fix: nginx — re-resolve upstream hostname via Docker DNS
Previously nginx resolved service names (api, ui) to IPs once at startup and cached them forever. When the api container is rebuilt (e.g. for a code fix) Docker assigns it a new IP and nginx keeps hitting the old dead one, returning 502 Bad Gateway on every request until nginx is manually restarted. Actual impact tonight: after deploying the Wownero 10^11 decimals fix, wowcheckout-api-1 came up at 172.20.0.6 but nginx kept trying 172.20.0.9. Medusa's provider.authorizePayment call via the LAN URL 502'd. Medusa treated that as 'payment not authorized', refused to create the order, and the customer's WOW payment silently vanished even though the reconciler detected it correctly on the xmrcheckout side. Use 'resolver 127.0.0.11 valid=10s' + 'set $api_upstream …' so nginx re-resolves via Docker's internal DNS every ~10s. Stale-IP window is now bounded to 10s max.
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
limit_req_zone $binary_remote_addr zone=global_rate_limit:10m rate=50r/s;
|
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 {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name wowcheckout.such.software localhost;
|
server_name wowcheckout.such.software localhost;
|
||||||
@@ -11,7 +19,8 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://api:8000/api/;
|
set $api_upstream "api";
|
||||||
|
proxy_pass http://$api_upstream:8000/api/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@@ -23,7 +32,8 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location = /openapi.json {
|
location = /openapi.json {
|
||||||
proxy_pass http://api:8000/openapi.json;
|
set $api_upstream "api";
|
||||||
|
proxy_pass http://$api_upstream:8000/openapi.json;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@@ -37,7 +47,8 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://ui:3000/;
|
set $ui_upstream "ui";
|
||||||
|
proxy_pass http://$ui_upstream:3000/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|||||||
Reference in New Issue
Block a user