Last active
June 26, 2017 11:33
-
-
Save jbutko/692d73f2a3b2b2f046a8a77953f593a2 to your computer and use it in GitHub Desktop.
Nginx: Restrict web access with basic auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install apache2-utils | |
# assign password to "customuser" user | |
sudo htpasswd -c /etc/nginx/.htpasswd customuser | |
# edit nginx conf usually located in /etc/nginx/sites-available/default or /etc/nginx/sites-available/customsite.com.conf | |
sudo nano /etc/nginx/sites-available/default | |
location / { | |
... | |
auth_basic "Private Property"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
} | |
# via https://www.digitalocean.com/community/tutorials/how-to-set-up-basic-http-authentication-with-nginx-on-ubuntu-14-04 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment