Skip to content

Instantly share code, notes, and snippets.

@fideloper
Last active December 1, 2023 08:20
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fideloper/9477321 to your computer and use it in GitHub Desktop.
Save fideloper/9477321 to your computer and use it in GitHub Desktop.
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