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: nginx allow and deny stop at the first match, so deny all goes last

Nginx
~/tips/tip-nginx-allow-deny-order

allow 192.168.1.0/24; allow 10.8.0.2;

Restricts a path to chosen addresses and refuses everyone else.

An admin area open only to the LAN needs three lines, and their order is the whole trick.

location /admin/ {
    allow 192.168.1.0/24; allow 10.8.0.2;
    deny  all;
}

The rules are checked in order and the first one that matches decides, so deny all at the top would block everybody. Blocked clients get a 403. nginx judges the address it sees, which behind another proxy is the proxy unless the real client IP is restored. With satisfy any; and auth_basic in the same location, a visitor passes by either having an allowed address or a valid password.

Further reading: ngx_http_access_module

Going deeper: ๐Ÿ›œ Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)

More Nginx tips sudo certbot --nginx -d example.com -d www.example.com /data/nginx/custom/server_redirect.conf map $http_upgrade $connection_upgrade { proxy_intercept_errors on; proxy_redirect http://localhost:3000/ /app/; All Nginx tips (50) All topics

Link