Skip to content

Instantly share code, notes, and snippets.

@jfriv
Last active March 3, 2018 17:33
Show Gist options
  • Save jfriv/10555816 to your computer and use it in GitHub Desktop.
Save jfriv/10555816 to your computer and use it in GitHub Desktop.
nginx catchall vhost config
server {
listen 80 default_server;
server_name _;
root /Users/MacbookPro/Sites/$host/;
autoindex on;
index index.html index.php;
# include php settings
include php.conf;
# if you don't like seeing all the errors for missing favicon.ico or robots.txt in root
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# add expires headers for static assets
location ~ ^/(js|css|img)/ {
access_log off;
expires 7d;
add_header Cache-Control public;
}
# deny access to sensitive files
location ~ /(\.ht|\.git|\.svn) {
deny all;
}
# try_files attempts to serve a file or folder, until it reaches the fallback at the end
try_files $uri $uri/ /index.php?$args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment