Skip to content

Instantly share code, notes, and snippets.

@chadrien
Last active December 15, 2015 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadrien/5208665 to your computer and use it in GitHub Desktop.
Save chadrien/5208665 to your computer and use it in GitHub Desktop.
Laravel nginx configuration
server {
listen 80;
server_name domain;
root /paht/to/public/;
index index.php;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
error_page 404 /index.php;
location ~ \..*/.*\.php$
{
# I'm pretty sure this stops people trying to traverse your site to get to other PHP files
return 403;
}
location ~ \.php(.*)$
{
# Pass the PHP files to PHP FastCGI for processing
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ /\.ht
{
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment