# 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