Skip to content

Instantly share code, notes, and snippets.

@arunjayakumar01
Created December 26, 2019 18:17
Show Gist options
  • Save arunjayakumar01/a9542a604e1e7fb698304399f4712c18 to your computer and use it in GitHub Desktop.
Save arunjayakumar01/a9542a604e1e7fb698304399f4712c18 to your computer and use it in GitHub Desktop.

htpasswd setup

sudo apt install apache2-utils

sudo touch /etc/nginx/htpasswd

sudo htpasswd /etc/nginx/htpasswd username

Enter password

to delete a user from the htpasswd file

sudo htpasswd -D /etc/nginx/htpasswd username

In nginx Vhost , inside the server block add the contents

location / {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/htpasswd;
    }

sudo nginx -t

sudo service nginx restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment