One Stopped Container Can Prevent nginx From Starting — Here Is the Fix
A single stopped Docker container can prevent nginx from starting entirely, taking down all proxied services including frontends and APIs. This happens because nginx resolves hostnames literally at config-parse time, making every upstream a hard startup dependency. The fix involves using a variable for proxy_pass targets along with Docker's internal DNS resolver, which defers resolution to request time and limits failures to a 502 on the affected route only. However, switching to variable-based proxy_pass breaks nginx's automatic URI prefix stripping, requiring manual rewrites for location blocks with trailing slashes. A further side effect involves CORS preflight handling, where the interaction between rewrite and if directives can cause subtle, hard-to-diagnose failures.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in