Skip to content

Instantly share code, notes, and snippets.

@ucotta
Last active January 24, 2017 11:40
Show Gist options
  • Save ucotta/b56932493a3146f074bca20a04265098 to your computer and use it in GitHub Desktop.
Save ucotta/b56932493a3146f074bca20a04265098 to your computer and use it in GitHub Desktop.
Add httpass authentication to nging
#!/bin/bash
# First step, prepare the .htpasswd file
# Add the user
sh -c "echo -n 'USERNAME:' >> /etc/nginx/.htpasswd"
# Then, add the password
sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
# Now, add it to your location
# auth_basic "Restricted Content";
# auth_basic_user_file /etc/nginx/.htpasswd;
# And now restart your server
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment