Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample Statamic 2 Nginx Conf
server {
listen 80;
server_name example.com;
root /var/www/example.com/public/;
ssl_protocols TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
# Dynamically set the try_files locations.
# Statically cached files should only be loaded for GET requests.
set $try_files @default;
if ($request_method = GET) {
set $try_files @static;
}
# The files to try when its a potentially static cache request (ie. a GET request)
location @static {
try_files /static${uri}_${query_string}.html @default;
}
# The files to try when it's not a static cache request (ie. anything other than GET)
location @default {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
try_files $uri $try_files; # Use the dynamically assigned locations from above.
}
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/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# Block access to hidden files (except the /.well-known/ dir)
location ~ /(?!.well-known)(\.)\w+ {
deny all;
}
# Block access to Statamic, content, and cache locations
location ~ ^\/(statamic|local|(site\/(?!themes))) {
deny all;
return 404;
}
# Enable gzip compression
# gzip on;
# gzip_min_length 1100;
# gzip_buffers 4 32k;
# gzip_types text/plain application/x-javascript text/xml text/css;
# gzip_vary on;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.