With a variable upstream ($ui_upstream, added for docker-DNS re-resolution),
a trailing-slash URI in proxy_pass makes nginx forward '/' to the UI for every
sub-path, so /_next/static/*.css and /i/<invoice> all return the app index HTML
(200 text/html) -> the UI renders unstyled and client routing breaks. Omit the
URI to preserve the full request path, matching the /api/ block.
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.