Skip to content

Instantly share code, notes, and snippets.

@poorcoder
Forked from fideloper/example.conf
Created September 13, 2016 05:33
Show Gist options
  • Save poorcoder/9f1f63ae21b73ebe8f2e1858f4279a32 to your computer and use it in GitHub Desktop.
Save poorcoder/9f1f63ae21b73ebe8f2e1858f4279a32 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