Skip to content

Instantly share code, notes, and snippets.

@chasevida
Last active January 8, 2016 16:27
Show Gist options
  • Save chasevida/1961f881afc58da13ecb to your computer and use it in GitHub Desktop.
Save chasevida/1961f881afc58da13ecb to your computer and use it in GitHub Desktop.
nginx.conf for silverstripe & homestead
server {
listen 80;
server_name sitename.local;
root /home/vagrant/path/to/directory/sitename;
index framework/main.php;
charset utf-8;
location / {
try_files $uri $uri/ /framework/main.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/sitename.local-error.log error;
error_page 404 /assets/error-404.html;
error_page 500 /assets/error-500.html;
sendfile off;
location ^~ /assets/ {
sendfile on;
try_files $uri = 404;
}
location ~ /framework/.*(main|rpc|tiny_mce_gzip)\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
location ~ /vendor/(.+)$ {
deny all;
}
location ~ /framework/sake$ {
deny all;
return 404;
}
location ~ /(cms|framework|mysite)/(.+).(php|php3|php4|php5|phtml|inc|rb|config|json|md)$ {
deny all;
}
location ^~ /silverstripe-cache {
deny all;
}
location ~* /(cms|framework)/silverstripe_version$ {
deny all;
}
location ~* \.(ya?ml|yml)$ {
deny all;
return 404;
}
location ~* web\.config {
deny all;
return 404;
}
location ~* nginx\.conf {
deny all;
return 404;
}
location ~* composer\.(json|lock) {
deny all;
return 404;
}
location ~ /\. {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment