Last active
December 15, 2015 05:20
-
-
Save chadrien/5208665 to your computer and use it in GitHub Desktop.
Laravel nginx configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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