Skip to content

Instantly share code, notes, and snippets.

@hamishforbes
Created January 17, 2014 09:51
Show Gist options
  • Save hamishforbes/8470813 to your computer and use it in GitHub Desktop.
Save hamishforbes/8470813 to your computer and use it in GitHub Desktop.
Example nginx conf for Matrix
# Push 404's to the matrix handler, this means static 404's in __data are handled by matrix too
error_page 404 = @matrix;
# Redirect server error pages to the static page /50x.html
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# Just serve data files
location /__data {
alias $matrix_root/data/public/;
expires 6h;
# There are php scripts in here too...
location ~ asset_types/.*\.php$ {
expires off;
fastcgi_split_path_info ^/__data/(.*)(.*);
fastcgi_pass $fcgi_path;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# Fudge and lib contain some php scripts, annoying.
location /__fudge {
alias $matrix_root/fudge/;
expires 6h;
location ~ \.php$ {
expires off;
fastcgi_split_path_info ^/__fudge/(.*)(.*);
fastcgi_pass $fcgi_path;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location /__lib {
alias $matrix_root/core/lib/;
expires 6h;
location ~ \.php$ {
expires off;
fastcgi_split_path_info ^/__lib/(.*)(.*);
fastcgi_pass $fcgi_path;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# Pass everything else to matrix handler
location / {
fastcgi_pass $fcgi_path;
fastcgi_param SCRIPT_FILENAME $document_root/core/web/index.php$fastcgi_script_name;
include fastcgi_params;
}
location @matrix {
fastcgi_pass $fcgi_path;
fastcgi_param SCRIPT_FILENAME $document_root/core/web/index.php$fastcgi_script_name;
include fastcgi_params;
}
# deny .inc, .FFV and CVS
location ~ \.inc$ {
deny all;
}
location ~ /(CVS|\.FFV)/ {
deny all;
}
server {
listen 80;
server_name localhost;
set $matrix_root /var/www/html/squiz_matrix;
set $fcgi_path unix:/var/run/php-fpm/www.sock;
root $matrix_root;
include conf.d/matrix-common;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment