nginx-proxy-manager/backend/lib/express
Tom Winnerl 18d4156c51 feat: test a host's config without saving (POST /api/nginx/<type>/test)
For proxy hosts, redirection hosts, 404 hosts and streams. The request
body is validated like a create/update (400 on invalid input), then the
host config goes through a dry run with nginx -t. The result says whether
nginx accepts the host, with the same humanised error a save would fail
with, the state of each custom location and the reachability of the
upstream targets, plus warnings (e.g. a certificate that would only be
requested on save, or broken configs of other hosts).

The dry run has no side effects: the host's file is only written for the
test, no meta is patched, no .err file is touched, nginx is not reloaded,
and broken files of other hosts are moved aside for the test and put back
byte-identical instead of being repaired. A host that doesn't exist yet is
rendered under a reserved, non-numeric name whose files are always removed.

Needs the create permission, or update when an id is given. As on save,
users who aren't admins can't test an advanced config of their own (403
before nginx -t runs; locations without one keep the saved one). Tests are rate
limited and the targets they probe count against the per user budget of
POST /upstreams/check (lib/upstream/check-budget.js); with the budget used
up nginx is still tested and the targets are reported as rate_limited.
Unit tests cover the result building and the dry run (an opt-in test,
NPM_TEST_NGINX=1, runs it against a real nginx).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:03:56 +01:00
..
cors.js Added PUT and DELETE method to Access-Control-Allow-Methods field 2026-05-12 09:24:28 +02:00
host-test-route.js feat: test a host's config without saving (POST /api/nginx/<type>/test) 2026-11-14 09:03:56 +01:00
jwt-decode.js Introducing the Setup Wizard for creating the first user 2025-10-02 08:12:05 +10:00
jwt.js Convert backend to ESM 2025-10-02 08:10:18 +10:00
log-request.js Fixes for upgraded debian trixie 2026-05-25 07:37:24 +10:00
pagination.js Updated backend packages 2026-08-22 23:10:26 +10:00
rate-limit.js Fix second round of review findings from PR #6029 2026-11-09 23:39:26 +10:00
user-id-from-me.js Updated backend packages 2026-08-22 23:10:26 +10:00