Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
default laravel nginx
server {
listen 80;
server_name my.domain.com;
root /opt/production/my-web;
index index.php;
rewrite_log on;
#access_log /var/log/nginx/access.log;
#error_log /var/log/nginx/error.log;
# Added cache headers for images, quick fix for cloudfront.
location ~* \.(png|jpg|jpeg|gif)$ {
expires 30d;
log_not_found off;
}
# Only 3 hours on CSS/JS to allow me to roll out fixes during
# early weeks.
location ~* \.(js|css|ico)$ {
expires 3h;
log_not_found off;
}
# Heres the redirect, try normal URI and then our Laravel urls.
location / {
try_files $uri $uri/ /index.php?$query_string;
# A bunch of perm page redirects from my old
# site structure for SEO purposes. Not interesting.
# include /etc/nginx/templates/redirects;
}
# common config for Laravel
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
location ~* \.php$ {
# Server PHP config.
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_split_path_info ^(.+\.php)(.*)$;
# Typical vars in here, nothing interesting.
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
# Hells no, we usin nginx up in this mutha. (deny .htaccess)
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment