Skip to content

Instantly share code, notes, and snippets.

@misuchiru03
Last active April 29, 2019 04:01
Show Gist options
  • Save misuchiru03/3006748d078be23652e9273f6c8c0529 to your computer and use it in GitHub Desktop.
Save misuchiru03/3006748d078be23652e9273f6c8c0529 to your computer and use it in GitHub Desktop.
Nginx web server standard web setup with static files, html, and php, with simple http auth support
server {
listen 443 ssl;
error_page 497 https://$server_name:$server_port$request_uri;
server_name www.domain.org;
error_log /var/log/nginx/www.error.log;
root /var/www/html/domain.org;
# Enable php support (must have php-fpm php-cli php-mysql php-gd php-imagick php-recode php-tidy php-xmlrpc installed for full support)
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
# File directories that server static files available for download, similar to FTP browsed via web
# Autoindex on; line states that the directory is served up as the index.html file, so files are seen
# For authentication, apache2-utils (debian) or httpd-tools (rhel) needs to be installed
location /filedirectory1/ {
auth_basic "Authentication Required to access this location.";
auth_basic_user_file /etc/nginx/.htpasswd;
autoindex on;
}
location /filedirectory2/ {
auth_basic "Authentication Required to access this location.";
auth_basic_user_file /etc/nginx/.htpasswd;
autoindex on;
}
location /filedirectory3/ {
auth_basic "Authentication Required to access this location.";
auth_basic_user_file /etc/nginx/.htpasswd;
autoindex on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment