How to password protect NGINX directories

TL;DR mc -e /etc/nginx/nginx.conf location / { auth_basic “Restricted”; auth_basic_user_file /home/domain//public_html/.htpasswd; } htpasswd -c /home/domain/public_html/.htpasswd username Now restart NGINX: # service nginx restart The / location is pretty important, and if you’re doing other stuff in there, e.g. with WordPress or Laravel friendly URL rewriting, then you have to combine like this: location / { … Continue reading How to password protect NGINX directories