Files
nginx-proxy-manager/test
Jamie Curnow 5b7e34eb67 Fix second round of review findings from PR #6029
Security
- Check advanced_config permissions before creating a certificate on
  host update (proxy, redirection and 404 hosts). A refused request
  previously requested a Let's Encrypt certificate first, leaving an
  orphan certificate and using up rate limit.
- Only trust X-NPM-Peer-Addr when it comes with a secret generated at
  container start. The admin nginx sends both headers. Any proxy host or
  stream forwarding to 127.0.0.1:3000 was also a loopback peer, so it
  could forge the header and get a fresh rate-limit bucket on every
  request. Without the secret (dev, or a mounted production.conf), the
  header is ignored.
- Add a login limit per IP across all accounts (30 failed attempts a
  minute) alongside the per-account one. Before this, one address could
  spray passwords over any number of accounts. Behind a shared proxy,
  everyone using that proxy shares this limit.
- Stop trusting X-Real-IP from loopback. It was only there for an older
  version of the rate limiter, and it let a stream host forwarding to a
  local proxy host forge the client IP and get past IP access lists.
  Loopback now behaves as it does on master.

Correctness
- Refuse to delete a certificate that hosts still use (400, with counts
  per host type). Their configs include its files, and a successful
  revoke deleted them anyway, which broke nginx -t. Otherwise the
  certificate is revoked and its files are removed even if the revoke
  fails.
- Let non-admins clear a location's advanced config. Deleting the
  location was already allowed and has the same effect, and a location
  deleted and re-added at the same path arrives with an empty config,
  which was refused.
- Clear proxy host grants (meta.proxy_host_ids) when visibility isn't
  "user" or proxy hosts are hidden, and drop ids of deleted hosts.
  Before, hidden grants came back when proxy hosts were shown again.
  The backend enforces this; the permissions modal also stops sending
  them.
- 404 host and redirection host modals now wait for the current user
  to load, so an admin's advanced config change isn't dropped if they
  submit before it loads.

Tests
- NonAdminHosts.cy.js: refused change doesn't create a certificate,
  location rename and clear rules, grant clearing.
- Certificates.cy.js: deleting a certificate that is in use.
2026-11-09 23:39:26 +10:00
..
2024-05-21 12:53:07 +10:00
2024-05-21 12:53:07 +10:00
2020-02-19 15:55:06 +11:00
2026-01-27 11:22:16 +10:00
2020-08-06 12:47:24 +10:00
2026-11-04 20:54:23 +10:00
2026-11-04 20:54:23 +10:00

Cypress Test Suite

Host Header Regression Test

Run python3 test/host-header-smoke.py <built-image> from the repository root. The backend CI build runs this check against the image it builds. It creates a disposable NPM container and renders a proxy host through the backend's normal configuration generator, including a custom location. A synthetic HTTPS upstream checks that the forwarded Host matches Origin and Referer, and echoes the request method, path and body. Coverage includes HTTP and HTTPS, explicit default and nonstandard ports, mixed-case names, IPv6 authorities, and HTTP/1.0 without Host. All test traffic and published Docker ports use loopback; the container and its anonymous volumes are removed on completion.

Running Locally

cd nginxproxymanager/test
yarn install
yarn run cypress

VS Code

Editor settings are not committed to the repository, typically because each developer has their own settings. Below is a list of common setting that may help, so feel free to try them or ignore them, you are a strong independent developer. You can add settings to either "user" or "workspace" but we recommend using "workspace" as each project is different.

ESLint

The ESLint extension only works on JavaScript files by default, so add the following to your workspace settings and reload VSCode.

"eslint.autoFixOnSave": true,
"eslint.validate": [
	{ "language": "javascript", "autoFix": true },
	"html"
]

NOTE: If you've also set the editor.formatOnSave option to true in your settings.json, you'll need to add the following config to prevent running 2 formatting commands on save for JavaScript and TypeScript files:

"editor.formatOnSave": true,
"[javascript]": {
	"editor.formatOnSave": false,
},
"[javascriptreact]": {
	"editor.formatOnSave": false,
},
"[typescript]": {
	"editor.formatOnSave": false,
},
"[typescriptreact]": {
	"editor.formatOnSave": false,
},

Forwarded Host image test

Run python3 test/host-header-smoke.py <built-image> from the repository root. The test waits for the manager, generated HTTP/HTTPS proxy host, both location paths and its synthetic upstream. It verifies Host/Origin/Referer consistency, request bodies and HTTP/1.0 fallback, then uses a dynamic upstream counter to prove cache hits and isolation between client authorities on ports 232 and 233. Requests run through docker exec, so a remote Docker daemon or containerized CI agent needs no shared loopback interface or published ports. The CI image build script invokes this test against the image it just built.