Skip to content

Instantly share code, notes, and snippets.

@rslhdyt
Created April 13, 2018 17:54
Show Gist options
  • Save rslhdyt/c0426fa9371c2f0abec84a1425e826d6 to your computer and use it in GitHub Desktop.
Save rslhdyt/c0426fa9371c2f0abec84a1425e826d6 to your computer and use it in GitHub Desktop.
Basic Auth Nginx configuration
# create encrypted password
# sudo sh -c "echo -n 'fpp:' >> /etc/nginx/.htpasswd"
# sudo sh -c "openssl passwd bar >> /etc/nginx/.htpasswd"
foo:BKlWoa/TUkUgc
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ =404;
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