$ sudo apt-get install nginx
$ sudo sh -c "echo -n '<username>:' >> /etc/nginx/.htpasswd"
$ sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
Password: <password>
Verifying - Password: <password>
$ sudo nano /etc/nginx/sites-enabled/default
server {
...
location / {
...
# BASIC Auth:
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
$ sudo service nginx restart
Created
June 23, 2017 03:53
-
-
Save akirattii/3fec706db572c35dd12185cb3a4c038c to your computer and use it in GitHub Desktop.
Super easy way of Basic Authenticatoin setup of nginx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment