Repository navigation
nginx: re-resolve service addresses so it survives docker compose restart - #13
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bF628vAWVF7d1gqS2bQwG Signed-off-by: Artem Savchenko <armisav@gmail.com>
nginx looked up service names once at startup. After 'docker compose restart' containers can come back with different IPs, and nginx kept proxying to the old ones: 502 (or another service) until nginx itself was restarted. Use Docker's DNS (127.0.0.11, valid=10s) and put upstreams in a variable so proxy_pass resolves them per request. 'set' goes before 'rewrite ... break', which would otherwise skip it, and prefixes are stripped with '^/_x/?(.*)$ -> /$1' so /_accounts still maps to / as before. Routing of all paths and query strings is unchanged (checked old vs new side by side). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bF628vAWVF7d1gqS2bQwG Signed-off-by: Artem Savchenko <armisav@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After
docker compose restartnginx could return 502 (or proxy to the wrong service): it resolved service names once at startup, and restarted containers can come back with different IPs. Seen in CI: nginx sent/_accountsto172.18.0.15, which by then wasfulltext;accountwas at172.18.0.3.Fix (
.huly.nginx)resolver 127.0.0.11 valid=10s ipv6=off;— Docker's DNS onhuly_netset $upstream http://account:3000; proxy_pass $upstream;), which makes nginx resolve them per request (cached 10s)setis placed beforerewrite ... break(breakskips later rewrite-module directives, includingset)rewrite ^/_x/?(.*)$ /$1 break;so/_accountsstill maps to/as with the oldproxy_pass http://account:3000/;Checked
/,/files?…,/_accounts,/_accounts/api/…?token=…,/_collaborator/…,/_transactor/<token>,/eyJ…,/_rekoni/…,/_stats/…?a=b&c=d, GET and POSTaccountandtransactor(new IPs) and re-runssmoke.sh --verify. With the old config the restart step failed again on this PR (ede6e6b); with the fix two runs in a row are green.🤖 Generated with Claude Code
https://claude.ai/code/session_012bF628vAWVF7d1gqS2bQwG
Generated by Claude Code