Skip to content

Instantly share code, notes, and snippets.

@GhazanfarMir
Last active September 30, 2016 21:45
Show Gist options
  • Save GhazanfarMir/d540f99daef38db67b1de3145f8f94c2 to your computer and use it in GitHub Desktop.
Save GhazanfarMir/d540f99daef38db67b1de3145f8f94c2 to your computer and use it in GitHub Desktop.
NGINX Implement Auth Basic
server {
listen 80;
server_name www.example.com
root /var/www/html/sites/example.com
## implementing Basic Authentication
auth_basic "Administrators Only Area"
auth_basic_user_file /etc/nginx/.htpasswd
}
# usage
# Create a file and add the user
# sudo htpasswd -c /etc/nginx/.htpasswd admin
# $new password: ******
# $retype new password: *****
## add another user
# sudo htpasswd /etc/nginx/.htpasswd GhazanfarMir
# $password: *********
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment