Skip to content

Instantly share code, notes, and snippets.

Last active Dec 5, 2017
What would you like to do?
server {
listen 80;
root /var/www/sites/public/dev.example/;
index index.html index.htm index.php;
access_log /var/log/nginx/example.com_access.log;
error_log /var/log/nginx/example.com_error.log;
charset utf-8;
open_file_cache max=2000 inactive=20s;
open_file_cache_valid 60s;
open_file_cache_min_uses 3;
open_file_cache_errors off;
gzip on;
gzip_comp_level 2;
gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript text/xml application/xml;
gzip_disable "MSIE [1-6]\.";
# Allow robots but disable logging
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
# Pretty url
location / {
try_files $uri $uri/ /index.php?$query_string;
error_page 404 /404.html;
location = /usr/share/nginx/error/404.html {
root /usr/share/nginx/error/;
error_page 500 502 503 504 /50x.html;
location = /usr/share/nginx/error/50x.html {
root /usr/share/nginx/error/;
# Caching assets
location ~ \.(js|css|png|jpg|gif|swf|ico|svg|xml)$ {
fastcgi_hide_header Set-Cookie;
open_file_cache max=2000 inactive=14d;
open_file_cache_errors off;
open_file_cache_min_uses 3;
open_file_cache_valid 1m;
output_buffers 1 2m;
expires 14d;
access_log off;
log_not_found off;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# enable only if you want nginx to intercept php errors and throw vauge nginx errors
#fastcgi_intercept_errors on;
# Deny access to htaccess and htpasswd files
location ~ /\.ht {
deny all;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment