Skip to content

Instantly share code, notes, and snippets.

@camilonova
Created November 9, 2017 21:09
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 camilonova/3e403ed8a946e9798bb70ac0a1cb2478 to your computer and use it in GitHub Desktop.
Save camilonova/3e403ed8a946e9798bb70ac0a1cb2478 to your computer and use it in GitHub Desktop.
How to make nginx password protected

Run this on the shell:

sudo sh -c "echo -n 'sammy:' >> /etc/nginx/.htpasswd"
sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"

Change nginx file to:

    location / {
        ...
        auth_basic "Restricted Content";
        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