i.e.: location ~* ^/foo/private/(.*) { alias /home/foo/web/private/$1/; auth_basic "Restricted files"; auth_basic_user_file /home/foo/web/private/$1/.htpasswd; } Thank you so much for your time and effort in nginx! Hopefully this is pretty trivial.