brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: rate limit your proxy hosts with http_top.conf and server_proxy.conf

Security
~/tips/tip-nginxproxymanager-rate-limit

limit_req_zone $binary_remote_addr zone=npmlimit:10m rate=10r/s;

Limits how many requests per second one client can send to your Nginx Proxy Manager hosts.

Nginx has a built-in request limiter. NPM does not show it in the UI, but its custom config files give you a place to hang it.

A limit needs two parts. The zone goes in the http block, so it belongs in http_top.conf. The limit itself can go in server_proxy.conf, which ends every proxy server block:

# /data/nginx/custom/http_top.conf
limit_req_zone $binary_remote_addr zone=npmlimit:10m rate=10r/s;

# /data/nginx/custom/server_proxy.conf
limit_req zone=npmlimit burst=20 nodelay;

Each client address may now do ten requests a second on average, with a burst of twenty. Anything beyond that is rejected. The Nginx docs say rejected requests get status 503 unless you set limit_req_status.

Caveat: a modern web app fires a lot of small requests at once, so a tight rate breaks pages that look fine. Start generous. And if NPM sits behind another proxy, every visitor may look like the same address, so the limit hits everyone together. Fix the client address first.

The zone name is yours to pick. The 10m is the size of the shared memory that remembers clients, and the Nginx docs use the same value in their own example. Ten megabytes is plenty for a home setup.

Further reading: Nginx Proxy Manager: Advanced Configuration, nginx.org: ngx_http_limit_req_module, On this site: raise the 413 upload limit for every proxy host with server_proxy.conf, On this site: tell Nginx which proxy to trust, so your apps see the real client IP

Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link