Skip to content

Instantly share code, notes, and snippets.

@Mulkave
Last active December 20, 2015 01:59
Show Gist options
  • Save Mulkave/6053053 to your computer and use it in GitHub Desktop.
Save Mulkave/6053053 to your computer and use it in GitHub Desktop.
A virtual host script for laravel projects
# NOTE: Assumes the existence of a conf directory with a php.conf inside if
# check https://gist.github.com/Mulkave/6053040 (Mulkave/nginx-php.conf)
server {
listen 80;
server_name [host];
root [document_root];
#charset koi8-r;
access_log /usr/local/var/log/[host].access.log;
error_log /usr/local/var/log/[host].error.log;
location / {
index index.php index.html index.htm;
try_files $uri /index.php?$query_string;
}
location /fonts/* {
add_header Access-Control-Allow-Origin *;
}
location ~* \.(ttf|eot|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|ttf|eot|woff)$ {
access_log off;
log_not_found off;
# Cache control
expires max;
add_header Cache-Control private;
}
location ~ \..*/.*\.php$ {
# This is to keep people away from listing other PHP files
return 403;
}
location /favicon.ico {
log_not_found off;
access_log off;
}
# proxy the PHP scripts to FPM
location ~ \.php$ {
include conf/php.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment