if ($request_method !~ ^(GET|HEAD|POST)$) {
return 444;
}
add_header Set-Cookie "wp-postpass=1;Domain=localhost;Path=/;Max-Age=100000";
"~:1" 0;
"$request_method:$check_query_string:$check_request_uri:$check_cookie"
set $cache_hit 1;
# POST requests and urls with a query string should always go to PHP.
if ($request_method = POST) {
set $cache_hit 0;
}
if ($query_string != "") {
set $cache_hit 0;
}
# Don't cache uris containing the following segments.
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_hit 0;
}
# Don't use the cache for logged-in users or recent commenters.
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_hit 0;
}
map $query_string $with_qs {
"" 0;
default 1;
}
map "$with_qs:$request_method" $is_post {
"1:~" 1;
"~:POST" 1;
default 0;
}
map "$is_post:$request_uri" $req_uri {
"1:~" 1;
"~:~*(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)" 1;
default 0;
}
map "$req_uri:$http_cookie" $skip_cache {
"1:~" 1;
"~:~*comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in" 1;
default 0;
}
map "$request_method:$query_string:$request_uri:$http_cookie" $cache_hit {
"POST:~:~:~" 0;
"~:~:~:~" 0;
"~:~:~*(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml):~" 0;
"~:~:~:~*comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in" 0;
default 1;
}
map $http_x_forwarded_for, $debug_ip_address {
default 78.139.151.52;
}
Source values are specified as strings or regular expressions (0.9.6).
http {
# Ip address for debuging purposes.
map $http_x_forwarded_for, $debug_ip_address {
default 78.139.151.52;
}
# Set debuggind flag, if User IP is whitelisted.
map $http_x_forwarded_for, $is_debug {
$debuging_ip_address 1;
default 0;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
add_header X-Caches-Flag $is_debug;
add_header X-Caches-MyIP $debug_ip_address;
add_header X-Caches-IP $http_x_forwarded_for;
}
}
x-caches-flag: 0
x-caches-ip: 78.139.151.52
x-caches-myip: 78.139.151.52