Skip to content

Instantly share code, notes, and snippets.

@khaledsaikat
Last active April 7, 2017 19:31
Show Gist options
  • Save khaledsaikat/fbe31939f3db6880feec0e3017344221 to your computer and use it in GitHub Desktop.
Save khaledsaikat/fbe31939f3db6880feec0e3017344221 to your computer and use it in GitHub Desktop.
Some nginx config inside server block: Using subdirectory, Server from another directory, Autoindex file listing, Using basic auth
##
# Some nginx config inside server block
#
# Examples of:
# * Using subdirectory
# * Server from another directory
# * Autoindex file listing
# * Using basic auth
#
# Install and using of htpasswd tools:
# sudo apt-get install apache2-utils
# sudo htpasswd -c /etc/nginx/.htpasswd sammy
##
location /logs/ {
try_files $uri $uri/ =404;
# Using as root directory
alias /var/www/logs;
# File listing
autoindex on;
# Basic auth
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