2012-08-06 13:17:44 +01:00
|
|
|
http {
|
2013-03-06 14:13:26 +00:00
|
|
|
...
|
|
|
|
upstream memcached-servers {
|
|
|
|
MEMCACHED_SERVERS
|
|
|
|
}
|
2012-08-06 13:17:44 +01:00
|
|
|
...
|
|
|
|
server {
|
|
|
|
...
|
|
|
|
|
2012-12-07 16:57:18 +00:00
|
|
|
# try to get result from memcached
|
2012-08-06 13:17:44 +01:00
|
|
|
location @memcached {
|
2012-12-07 16:57:18 +00:00
|
|
|
default_type text/html;
|
|
|
|
set $memcached_key DATAPREFIX$scheme://$host$request_uri;
|
|
|
|
set $memcached_request 1;
|
|
|
|
|
|
|
|
# exceptions
|
|
|
|
# avoid cache serve of POST requests
|
|
|
|
if ($request_method = POST ) {
|
|
|
|
set $memcached_request 0;
|
|
|
|
}
|
|
|
|
# avoid cache serve of wp-admin-like pages, starting with "wp-"
|
|
|
|
if ( $uri ~ "/wp-" ) {
|
|
|
|
set $memcached_request 0;
|
|
|
|
}
|
|
|
|
# avoid cache for logged in users
|
|
|
|
if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_" ) {
|
|
|
|
set $memcached_request 0;
|
|
|
|
}
|
2012-02-21 06:50:25 +00:00
|
|
|
|
2012-12-07 16:57:18 +00:00
|
|
|
if ( $memcached_request = 1) {
|
2013-03-06 14:13:26 +00:00
|
|
|
memcached_pass memcached-servers;
|
2012-12-07 16:57:18 +00:00
|
|
|
error_page 404 = @rewrites;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $memcached_request = 0) {
|
|
|
|
rewrite ^ /index.php$request_uri last;
|
|
|
|
}
|
2012-08-06 13:17:44 +01:00
|
|
|
}
|
|
|
|
|
2012-12-07 16:57:18 +00:00
|
|
|
## rewrite rules
|
2012-08-06 13:17:44 +01:00
|
|
|
location @rewrites {
|
2012-12-07 16:57:18 +00:00
|
|
|
rewrite ^ /index.php$request_uri last;
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
try_files $uri $uri/ @memcached;
|
2012-08-06 13:17:44 +01:00
|
|
|
}
|
2012-08-16 11:33:56 +01:00
|
|
|
|
2012-08-06 13:17:44 +01:00
|
|
|
...
|
|
|
|
}
|
2012-02-21 06:50:25 +00:00
|
|
|
}
|
2012-08-06 13:17:44 +01:00
|
|
|
...
|