Last active
December 1, 2023 08:20
-
-
Save fideloper/9477321 to your computer and use it in GitHub Desktop.
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 { | |
# Redirect any subdomain to the root domain | |
# to be captured by next server block | |
server_name *.example.com; | |
return 301 $scheme://example.com$request_uri; | |
} | |
server { | |
root /var/www; | |
index index.html index.htm; | |
# Make site accessible from http://example.com | |
server_name example.com | |
access_log /var/log/nginx/example.com-access.log; | |
error_log /var/log/nginx/example.com-error.log error; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
# Don't log favicon.ico nor robots.txt attempts | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { log_not_found off; access_log off; } | |
error_page 404 /error404.html | |
# Deny .htaccess file access | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment