Nginx Proxy Guard

Features

Security headers and rate limits

This page covers two settings.

  • Security headers: HTTP response headers such as HSTS and X-Frame-Options added to a proxy host's responses, so browsers apply protections like forced HTTPS and frame blocking.
  • Rate limit: a limit on how many requests per second one client may send, enforced with nginx limit_req. Requests over the limit are refused with 429 (or 503).

Both follow the same pattern: you set a global default once, and each host chooses Inherit, Override or Disable. The pattern itself is described in Global security defaults.

Where it is

ScopeLocation
Per hostProxy host → edit → Protection tab, sections Security Headers and Rate Limit
Global security headers defaultWAF / Blocking → Global Security Headers
Global rate limit defaultWAF / Blocking → Global Rate Limit

The Protection tab becomes available after the host has been saved once. While you create a new host it shows "Protection settings available after saving". Changes on this tab are saved automatically about one second after you stop editing.

WAF / Blocking → Global Security Headers
WAF / Blocking → Global Security Headers

Security headers

Settings

FieldValuesHeader sent
HSTS (HTTP Strict Transport Security) → Enableon/offStrict-Transport-Security: max-age=31536000
Include Subdomainson/offadds ; includeSubDomains to the HSTS value
X-Frame-OptionsDENY, SAMEORIGIN, NoneX-Frame-Options
Referrer-Policyno-referrer, strict-origin, strict-origin-when-cross-originReferrer-Policy
X-Content-Type-Options: nosniffon/offX-Content-Type-Options: nosniff
X-XSS-Protectionon/offX-XSS-Protection: 1; mode=block

The global default starts with HSTS on (one year, subdomains included), SAMEORIGIN, strict-origin-when-cross-origin, nosniff on and X-XSS-Protection on. The Global Security Headers toggle itself starts off, so hosts that inherit get no headers until you turn it on. New proxy hosts start on Inherit.

The HSTS max-age is fixed at one year (31536000 seconds) and cannot be changed in the panel. No preload directive is sent.

Content-Security-Policy and Permissions-Policy

These two headers break sites easily when they are wrong, so the form does not offer them. If you need them, add them to the custom nginx configuration on the proxy host's Advanced tab.

add_header Content-Security-Policy "default-src 'self'" always;
add_header Permissions-Policy "camera=(), microphone=()" always;

Rate limit

WAF / Blocking → Global Rate Limit
WAF / Blocking → Global Rate Limit

Settings

FieldDescription
Requests per SecondThe sustained number of requests per second allowed for one client (per the Limit By key).
Burst SizeHow many extra requests a short burst may add. Requests beyond that are refused immediately (nodelay).
Limit ByHow requests are grouped: IP Address, URI or IP + URI.
Response CodeThe code returned when the limit is exceeded: 429 Too Many Requests or 503 Service Unavailable.
Whitelist IPsIP addresses and CIDR ranges that are not limited, separated by commas or line breaks; a trailing # comment is allowed. An invalid value is named and the save is refused.
DomainsA domain whose address changes, such as a DDNS name. NPG looks it up on a schedule and treats the addresses like whitelist entries. Those addresses still get the WAF and bans.

When a host chooses Override, the form starts at 50 requests per second, burst 100, IP Address and 429. The global default starts with the same values, and the Global Rate Limit toggle starts off.

How it works

  • Each host has its own counter (an nginx limit_req zone). Hosts that inherit the global default share the values, not the count.
  • GET and HEAD requests whose path ends in a static file extension (js, css, png, jpg, jpeg, gif, ico, svg, woff, woff2, ttf, eot, webp, avif, mp4, webm, pdf, zip, tar, gz, rar) are not counted. A path containing ;, or a script followed by more path (such as /index.php/x.css), is not treated as a static file and is counted.
  • Whitelist IPs, addresses of the listed domains and Global Trusted IPs (Settings → WAF Auto-Ban) are not counted.
  • Refused requests appear in Logs → Access Logs with the block reason Rate Limit.

Difference from the global DDoS protection

Settings → Global Settings → Advanced has a DDoS Protection (Global) section with Request Rate Limit, Connection Limit and Bandwidth Limit. These are per-IP limits for all of nginx (the http block): one counter covers requests to every host, and static files are counted too. The per-host rate limit applies in addition. Both skip Global Trusted IPs, and requests refused by either are logged with the block reason Rate Limit.

How it works with other features

  • The admin panel's API has its own rate limit (API_RATE_LIMIT_PER_MINUTE and others). It is unrelated to this setting and is set in Environment variables.
  • Trusted IPs, exceptions and precedence lists which trusted lists exempt a client from the rate limit.
  • Behind Cloudflare or another proxy, set Settings → Trusted Proxies so the rate limit counts visitors' addresses rather than the proxy's. See Running behind Cloudflare.

Limits

  • The HSTS max-age and preload cannot be changed in the panel.
  • Content-Security-Policy and Permissions-Policy have to be written in the advanced configuration.
  • The per-host rate limit counts requests only, not connections or bandwidth. Connection and bandwidth limits exist only in the global DDoS protection above.