nginx-proxy-manager/backend
Tom Winnerl 07917e1893 fix(review): quarantine a location behind an error without a line
Problem: a custom location with `proxy_set_header X-Test $missing_variable;`
still blocked the whole host save. nginx reports `unknown "missing_variable"
variable` without file or line (variables are checked after parsing), so the
error never reached the per-location quarantine, which needs a line inside a
location's markers. The check without this host passed, so the save was
rejected as a "conflict with another host"; in bulk mode (startup, repair of
another host) the whole host went offline instead of the one location.

Fix: lib/nginx-locations.js gets isolateFaultyLocations(). When an error has
no line and only this host's config causes it (no file named and the test
without the host passes, or the host's file named without a line),
configureHost() stubs the rendered locations: if the error stays with all of
them stubbed it comes from the host itself and the result is unchanged.
Otherwise each location is rendered alone with all the others still stubbed,
and every one that brings the same error back is quarantined. Two broken
locations with the same message are thus both found, and a working location
is never quarantined for them (stubbing one at a time would leave the other's
identical error and blame every candidate). Only when none fails alone (they
fail only together) is each one stubbed alone and the first that makes the
error go away (or change) quarantined, all of them when none does. The loop
then tests the full config again, bounded by maxQuarantines as before. In a
nested configure it is skipped when the host being saved is the cause
(causedByProtected() handles that as before). After the search the config
that failed is written back to the host's file, so a host rejected at host
level in bulk mode keeps its real config as .err for inspection, not the last
stubbed variant.

When no location is to blame (the error stays with all of them stubbed,
or the host has none), the host level check from the feat(nginx) commit
applies as before: the host is only rejected as a conflict with another
host when the error goes away with every other host's config moved aside
(failsAlone()), otherwise it fails with a host level error such as
`Advanced configuration: unknown variable "$x"`.

Tests: nginx-location-isolate.test.js with unit tests for the search and
configureHost() against a fake nginx -t that reports unknown variables
without a line: the bad location is quarantined (503 stub) and the host
stays online; two bad locations with different variables are both
quarantined; two bad locations with the same variable around a clean one
quarantine only the two, the clean one stays ok; the same variable in the
host's advanced config still rejects the host at host level with an
"Advanced configuration" message (not a conflict with another host), also
for a host without locations, and in bulk mode its .err file holds the
real config (proxy_pass, the variable), not 503 stubs, and its nginx_err
names the advanced configuration.

Cypress (ProxyHostLocations): a location with `$missing_variable` is
quarantined with an unknown-variable message, the host stays online, its
other location serves and the bad one answers 503.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:03:56 +01:00
..
certbot Merge pull request #5951 from Alexis-Loskoutoff/fix/update-infomaniak-certbot-plugin 2026-11-05 10:03:35 +10:00
config Update SQLite client configuration from sqlite3 to better-sqlite3 2026-02-14 23:53:43 -08:00
internal fix(review): quarantine a location behind an error without a line 2026-11-14 09:03:56 +01:00
lib fix(review): quarantine a location behind an error without a line 2026-11-14 09:03:56 +01:00
migrations feat: rate limit auth endpoints and scope user proxy host permissions 2026-11-05 12:16:36 +05:00
models Optimise isAdmin lookups 2026-11-09 22:25:07 +10:00
routes Fix second round of review findings from PR #6029 2026-11-09 23:39:26 +10:00
schema feat(nginx): render custom locations on their own, quarantine the broken ones 2026-11-14 09:03:56 +01:00
scripts fix(review): exit non-zero when regenerate-config could not configure a host 2026-11-13 19:19:31 +01:00
templates fix(review): keep forward paths with nginx variables literal 2026-11-14 09:03:56 +01:00
test fix(review): quarantine a location behind an error without a line 2026-11-14 09:03:56 +01:00
.gitignore
app.js feat(nginx): serialised configure that tests, rolls back and repairs other hosts 2026-11-11 13:47:08 +01:00
biome.json Update dependencies 2026-11-09 11:55:20 +10:00
db.js Updated backend packages 2026-08-22 23:10:26 +10:00
index.js feat(nginx): render custom locations on their own, quarantine the broken ones 2026-11-14 09:03:56 +01:00
knexfile.js Updated backend packages 2026-08-22 23:10:26 +10:00
logger.js feat: Add a Logs viewer to the admin UI 2026-09-22 13:11:38 -03:00
migrate.js Attempt to fix race condition with database instantiation 2025-11-07 09:46:00 +10:00
nodemon.json
package.json test(backend): nginx error parsing, blame, lock and advanced config checks 2026-11-11 13:48:58 +01:00
setup.js Merge branch 'develop' into develop 2026-09-23 18:53:06 +07:00
validate-schema.js
yarn.lock Update dependencies 2026-11-09 11:55:20 +10:00