A worked example
A shop serves its assets from a folder and wants them cached for a day. The server block sets two security headers:
server {
listen 443 ssl;
server_name shop.example.com;
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Content-Type-Options nosniff;
location /assets {
alias /srv/shop/assets/;
add_header Cache-Control "public, max-age=86400";
}
}
What node check.mjs shop.conf prints:
shop.conf:8: [high] alias-path-traversal
location /assets has no trailing slash but alias /srv/shop/assets/ has one, so a request for /assets../ maps to the directory above the alias (the "off-by-slash" traversal): /assets../secret reads /srv/shop/assets/../secret.
fix: Make the two match: location /assets/ with alias /srv/shop/assets/, or drop the slash from both.
shop.conf:9: [medium] add-header-drops-inherited
This location block sets its own add_header, so nginx stops sending the add_header lines from the enclosing level here: Strict-Transport-Security (shop.conf:4), X-Content-Type-Options (shop.conf:5). Responses from this block go out without them.
fix: On nginx 1.29.3 or later, add add_header_inherit merge; to this block or the http block. On older versions, repeat the dropped add_header lines in this block (an include file of shared headers keeps them in one place).
2 findings: 1 high, 1 medium. (1 file read)
Two lines, two holes: anything in /srv/shop/ beside the assets folder is downloadable, and every asset response goes out without HSTS or nosniff. Neither shows up in testing, because the site works.
alias-path-traversal: the off-by-slash
A prefix location matches any URI that starts with its string, and alias replaces that matched part with the alias path. With location /assets and alias /srv/shop/assets/, the URI /assets../config.php matches (it starts with /assets) and becomes /srv/shop/assets/../config.php, one level up. nginx does not collapse assets.., because that path segment is not .. on its own. The fix is to make the slashes agree: location /assets/ with alias /srv/shop/assets/. When the location path ends the same way as the alias path, root is simpler: location /assets/ { root /srv/shop; }.
crlf-injection-uri: $uri where $request_uri belonged
The core module documents $uri as the current URI "in request, normalized", and normalising decodes percent-escapes. So %0d%0a in the path becomes a real carriage return and line feed inside $uri. Put it in return 301 https://$host$uri; and a crafted link makes nginx send a Location header followed by headers the attacker wrote (a cookie, a second redirect, a cache directive). The same goes for add_header, a redirecting rewrite, proxy_set_header and the path part of proxy_pass (where it splits the request to your upstream). $request_uri is the full original request URI with its encoding intact, so the redirect is return 301 https://$host$request_uri;.
add-header-drops-inherited: one header switches off the rest
From ngx_http_headers_module: add_header directives "are inherited from the previous configuration level if and only if there are no add_header directives defined on the current level." A location, or an if inside one, that adds a single Cache-Control header loses every add_header from server and http. The checker lists which headers are dropped. nginx 1.29.3 added add_header_inherit: merge appends the inherited headers to this level's, and off drops them deliberately; the checker honours both. On older versions, keep shared headers in one include file and include it in every block that sets its own.
ssrf-upstream-from-request and ssrf-upstream-from-host
When proxy_pass contains variables, nginx builds the upstream address from them on every request (resolving names with the configured resolver). proxy_pass http://$arg_target; lets anyone pick the address: an internal admin panel, a database's HTTP port, a cloud metadata endpoint. $http_* headers and $cookie_* are just as client-controlled. $host is safer only if the server answers a fixed server_name, because nginx fills it from the request line or the Host header first. Proxy to a named upstream or a fixed host; if the target must vary, map the request value to an allow-list.
cors-reflects-any-origin and origin-regex-unanchored
add_header Access-Control-Allow-Origin $http_origin; echoes whatever origin asked, which is the same as allowing every site. With Access-Control-Allow-Credentials true it is worse than * (which browsers refuse to combine with credentials): any page a logged-in user visits can read your API's responses as that user. Guards built from a regex often leak too. if ($http_origin ~* "example.com") also matches https://example.com.attacker.net (no $), https://attacker.net/?example.com (no ^) and https://exampleXcom.net (unescaped dot). Anchor and escape it: ~ ^https://(www\.)?example\.com$, ideally in a map whose result is the header value.
deny-after-allow-all
ngx_http_access_module checks rules "in sequence until the first match is found". After allow all; nothing further is reached, so a later deny 203.0.113.7; never blocks anything. List the denies first, or flip the block to specific allows followed by deny all;.
autoindex-on and status-page-public
autoindex on lists a directory's files when there is no index file, including backups, dumps and anything copied there by mistake. stub_status publishes active connections and request counts; harmless alone, but it should sit behind allow/deny or authentication like any other operational endpoint. The checker treats a server that listens only on 127.0.0.1, [::1] or a Unix socket as private.
open-redirect
return 302 $arg_next; sends visitors wherever the link says, on your domain's reputation: a classic phishing helper. Redirect to a fixed host, and pass the path as a parameter if you must.
ssl-protocol-broken, ssl-protocol-deprecated, ssl-cipher-weak
SSLv2 is prohibited by RFC 6176 and SSLv3 by RFC 7568; RFC 8996 deprecates TLS 1.0 and 1.1. nginx's default ssl_protocols has been TLSv1.2 TLSv1.3 since 1.23.4, so the simplest fix is often to delete the line. RC4, DES and 3DES, export-grade, NULL and anonymous cipher suites are flagged unless they are excluded with !; a published profile such as Mozilla's "intermediate" is a sound starting point.
The low-severity ones
- server-tokens-on:
server_tokens on(the default) puts the version in theServerheader and error pages. Hiding it does not fix a vulnerable version, but it stops advertising which one you run. - host-header-spoofing:
proxy_set_header Host $http_hostforwards the client's header exactly, even when it names another site or is empty;$hostfalls back to the matched server name. - upstream-tls-unverified:
proxy_ssl_verifydefaults tooff, soproxy_pass https://...to another machine is encrypted but unauthenticated until you turn it on with a trusted CA file. - valid-referers-none:
noneaccepts requests with noReferer, which is what any script sends by leaving it out. Referer checks are hotlink deterrents, not access control. - unbounded-request-body:
client_max_body_size 0disables the body size check (the default is 1m).
What the checker cannot see
It reads files, so it does not know your nginx version, the values a map, geo or set produces, the application behind proxy_pass, or files you did not paste (an include that matches nothing is reported as a note). A clean scan means these patterns were not found, not that the server is secure. Run nginx -t as well, and check the headers your live server sends with the Security Headers Check.