Skip to content

Instantly share code, notes, and snippets.

@alexishida
Created August 4, 2017 00:24
Show Gist options
  • Select an option

  • Save alexishida/161ab4dcd34b215127f394237bd5d341 to your computer and use it in GitHub Desktop.

Select an option

Save alexishida/161ab4dcd34b215127f394237bd5d341 to your computer and use it in GitHub Desktop.
http Basic Auth nginx
sudo sh -c "echo -n 'usuario:' >> /etc/nginx/.htpasswd"
sudo sh -c "openssl passwd senha >> /etc/nginx/.htpasswd"
cat /etc/nginx/.htpasswd
# Config do nginx
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
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