Skip to content

Instantly share code, notes, and snippets.

@blikenoother
Created May 18, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blikenoother/cf0299cb033f9182e030f472e159efc0 to your computer and use it in GitHub Desktop.
Save blikenoother/cf0299cb033f9182e030f472e159efc0 to your computer and use it in GitHub Desktop.
# package for generating .htpasswd file
sudo apt-get install apache2-utils
# create .htpasswd file
sudo htpasswd -c /etc/nginx/.htpasswd username (this will prompt you for password)
# add following 2 line in nginx config (/etc/nginx/sites-available/test.com)
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
# sample config file
server {
server_name test.com www.test.com;
root /opt/test;
index index.html;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment