fix(proxy): only reload nginx-proxy when its config test passes#494
Open
mrrobot47 wants to merge 1 commit into
Open
fix(proxy): only reload nginx-proxy when its config test passes#494mrrobot47 wants to merge 1 commit into
mrrobot47 wants to merge 1 commit into
Conversation
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.
Problem
reload_global_nginx_proxy()gated the proxy reload onif ( \EE::launch( '... nginx -t' ) ). ButEE::launch()defaults to returning aProcessRunobject (not an exit code), and every object is truthy in PHP — so theifwas always true and the config was regenerated and reloaded regardless of whethernginx -tpassed. A broken nginx config (e.g. from a half-written cert pair or a malformed vhost rule) was therefore reloaded and persisted; the shared proxy then fails to start on its next restart, taking down every site behind it.Compounding bug:
nginx -talso ran before the docker-gen regeneration, so it validated the pre-regeneration config rather than thedefault.confthat actually gets served.Fix
Regenerate
default.conffirst, then capture thenginx -tProcessRunand gate on0 === $test->return_code. On failure, warn with the test output and skip the reload (returnfalse); on success, reload. This mirrors the workingnginx -t && nginx -s reloadpattern already used elsewhere in the codebase.Notes
falseand emits anEE::warning, but wiring callers to react to that is a separate change.Testing
Manual (needs the EE + Docker harness): introduce an invalid proxy config (bad cert/vhost), trigger a reload, and confirm it warns and does NOT reload/persist the broken config; with a valid config, confirm normal regenerate + reload.