-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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