-
-
Save em-piguet/d169e9ad71d9228d8215 to your computer and use it in GitHub Desktop.
nginx config setup for modx + statcache
This file contains hidden or 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 { | |
root /path/to/site; | |
index index.php; | |
server_name somedomain.co.uk www.somedomain.co.uk; | |
set $cache_uri $request_uri; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { | |
set $cache_uri 'null cache'; | |
} | |
#loose any caching on querystring items | |
if ($query_string != "") { | |
set $cache_uri 'null cache'; | |
} | |
add_header X-UA-Compatible IE=edge,chrome=1; | |
error_page 418 = @nocache; | |
recursive_error_pages on; | |
location / { | |
if ($http_cookie ~ 'noCache=1') { | |
return 418; | |
} | |
if ($request_method = POST ) { | |
return 418; | |
} | |
# try the statcache - otherwise use modx | |
try_files /core/cache/statcache/web/$uri~index.html /core/cache/statcache/web/$uri $uri $uri/ @modx; | |
} | |
location @modx { | |
rewrite ^/(.*)$ /index.php?q=$1&$args; | |
} | |
location @nocache { | |
try_files $uri $uri/ @modx; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
set $skip_cache 1; | |
if ($cache_uri != "null cache") { | |
add_header X-Cache-Debug "$cache_uri $cookie_nocache $arg_nocache$arg_comment $http_pragma $http_authorization"; | |
set $skip_cache 0; | |
} | |
fastcgi_pass_header Set-Cookie; | |
fastcgi_buffers 64 4k; | |
include fastcgi_params; | |
fastcgi_param production "true"; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_pass php5-fpm-sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_intercept_errors on; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment