enhance virtual host configs

This commit is contained in:
joglomedia
2019-09-03 17:21:29 +07:00
parent 334ae073bb
commit d6b65c4d9c
16 changed files with 43 additions and 503 deletions

View File

@@ -4,3 +4,5 @@ Default virtual host site files
Each of these files is intended to be included in a server block directive.
Not all of the files here are used - they are available to be included as required.
As LEMPer stack requirements, please DO NOT remove any files contained here.
DO NOT DELETE/MODIFY these files, unless you know the result !!

View File

@@ -6,6 +6,9 @@ try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
# Uncomment to enable naxsi on this location
# Uncomment to enable CORS.
#include /etc/nginx/includes/cors.conf
# Uncomment to enable naxsi WAF.
#include /etc/nginx/naxsi.rules
}

View File

@@ -16,5 +16,3 @@ location / {
# Uncomment to enable naxsi on this location
#include /etc/nginx/naxsi.rules
}
## DO NOT DELETE this file, unless you know the result.

View File

@@ -1,63 +0,0 @@
## Default site rules with FastCGI cache enabled.
# Designed to be included in any server {} block.
## FastCGI Cache Rules.
# Ref: http://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
# Ref: https://gist.github.com/magnetikonline/10450786
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP.
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
if ($http_x_custom_header) {
set $skip_cache 0;
}
# Skip cache on admin pages
if ($request_uri ~* "(/admin/*|/backend/*|/dashboard/*)") {
set $skip_cache 1;
}
# Skip cache for uris containing the following segments.
if ($request_uri ~* "(apc.php|(mem|op)cache.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Skip cache for logged in cookies, you can customize this rule according to your cookie setting.
if ($http_cookie ~ "users_login_cookie") {
set $skip_cache 1;
}
# Purge cache.
location ~ /purge(/.*) {
#access_log off;
fastcgi_cache_purge FASTCGICACHE "$scheme$request_method$host$request_uri";
return 301 $scheme://$server_name;
allow 127.0.0.1;
deny all;
}
## End FastCGI Cache Rules.
## Default site directives.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
# Enables directory listings when index file not found.
autoindex on;
# Shows file listing times as local time.
autoindex_localtime on;
try_files $uri $uri/ /index.php?$args;
# Uncomment to enable naxsi on this location
#include /etc/nginx/naxsi.rules
}

View File

@@ -11,5 +11,3 @@ location / {
# Uncomment to enable naxsi on this location
#include /etc/nginx/naxsi.rules
}
## DO NOT DELETE this file, unless you know the result.

View File

@@ -20,7 +20,8 @@ location ~ /app/bundles/.*/Assets/ {
access_log off;
}
location ~ /app/ {
# Deny all php files in themes folder
location ~* ^/themes/(.*)\.php {
deny all;
}
@@ -33,24 +34,3 @@ location ~ /app/ {
#location ~ /(addons|plugins)/ {
# deny all;
#}
# Deny all php files in themes folder
location ~* ^/themes/(.*)\.php {
deny all;
}
# Deny yml, twig, markdown, init file access
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny all grunt, composer files
location ~* (Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
}
## DO NOT DELETE this file, unless you know the result.

View File

@@ -1,64 +0,0 @@
# BEGIN Better WP Security
location ~ /\.ht { deny all; }
location ~ wp-config.php { deny all; }
location ~ readme.html { deny all; }
location ~ readme.txt { deny all; }
location ~ /install.php { deny all; }
set $susquery 0;
set $rule_2 0;
set $rule_3 0;
rewrite ^wp-includes/(.*).php /not_found last;
rewrite ^/wp-admin/includes(.*)$ /not_found last;
if ($request_method ~* "^(TRACE|DELETE|TRACK)"){ return 403; }
location /wp-comments-post.php {
valid_referers jetpack.wordpress.com/jetpack-comment/ *.joglohosting.com;
set $rule_0 0;
if ($request_method ~ "POST"){ set $rule_0 1$rule_0; }
if ($invalid_referer) { set $rule_0 2$rule_0; }
if ($http_user_agent ~ "^$"){ set $rule_0 3$rule_0; }
if ($rule_0 = "3210") { return 403; }
}
if ($args ~* "\.\./") { set $susquery 1; }
if ($args ~* ".(bash|git|hg|log|svn|swp|cvs)") { set $susquery 1; }
if ($args ~* "etc/passwd") { set $susquery 1; }
if ($args ~* "boot.ini") { set $susquery 1; }
if ($args ~* "ftp:") { set $susquery 1; }
if ($args ~* "http:") { set $susquery 1; }
if ($args ~* "https:") { set $susquery 1; }
if ($args ~* "(<|%3C).*script.*(>|%3E)") { set $susquery 1; }
if ($args ~* "mosConfig_[a-zA-Z_]{1,21}(=|%3D)") { set $susquery 1; }
if ($args ~* "base64_encode") { set $susquery 1; }
if ($args ~* "(%24&x)") { set $susquery 1; }
if ($args ~* "(\[|\]|\(|\)|<|>|ê|\"|;|\?|\*|=$)"){ set $susquery 1; }
if ($args ~* "(&#x22;|&#x27;|&#x3C;|&#x3E;|&#x5C;|&#x7B;|&#x7C;|%24&x)"){ set $susquery 1; }
if ($args ~* "(127.0)") { set $susquery 1; }
if ($args ~* "(%0|%A|%B|%C|%D|%E|%F)") { set $susquery 1; }
if ($args ~* "(globals|encode|localhost|loopback)") { set $susquery 1; }
if ($args ~* "(request|select|insert|concat|union|declare)") { set $susquery 1; }
if ($http_cookie !~* "wordpress_logged_in_" ) {
set $susquery 2$susquery;
set $rule_2 1;
set $rule_3 1;
}
if ($args !~ "^loggedout=true") { set $susquery 3$susquery; }
if ($susquery = 4321) { return 403; }
rewrite ^/login/?$ /wp-login.php?np5eou1moyhmux2kmzyps redirect;
if ($rule_2 = 1) { rewrite ^/dashboard/?$ /wp-login.php?np5eou1moyhmux2kmzyps&redirect_to=/wp-admin/ redirect; }
if ($rule_2 = 0) { rewrite ^/dashboard/?$ /wp-admin/?np5eou1moyhmux2kmzyps redirect; }
rewrite ^/register/?$ /wp-login.php?np5eou1moyhmux2kmzyps&action=register redirect;
if ($uri !~ "^(.*)admin-ajax.php") { set $rule_3 2$rule_3; }
if ($http_referer !~* wp-admin ) { set $rule_3 3$rule_3; }
if ($http_referer !~* wp-login.php ) { set $rule_3 4$rule_3; }
if ($http_referer !~* login ) { set $rule_3 5$rule_3; }
if ($http_referer !~* dashboard ) { set $rule_3 6$rule_3; }
if ($http_referer !~* register ) { set $rule_3 7$rule_3; }
if ($args !~ "^action=logout") { set $rule_3 8$rule_3; }
if ($args !~ "^np5eou1moyhmux2kmzyps") { set $rule_3 9$rule_3; }
if ($args !~ "^action=rp") { set $rule_3 0$rule_3; }
if ($args !~ "^action=register") { set $rule_3 a$rule_3; }
if ($args !~ "^action=postpass") { set $rule_3 b$rule_3; }
if ($rule_3 = ba0987654321) {
rewrite ^(.*/)?wp-login.php /not_found redirect;
rewrite ^/wp-admin(.*)$ /not_found redirect;
}
# END Better WP Security

View File

@@ -1,7 +1,8 @@
## WordPress Multisite rules.
# Designed to be included in any server {} block.
# We're utilizing the Wordpress Singlesite configuration in site_wordpress.conf, since the basic rules & directives is the same.
# We're utilizing the Wordpress Singlesite configuration in site_wordpress.conf,
# since the basic rules & directives is the same.
include /etc/nginx/vhost/site_wordpress.conf;
## Below the Multisite specific stuff.

View File

@@ -1,34 +0,0 @@
## WordPress Multisite rules with FastCGI cache enabled.
# Designed to be included in any server {} block.
## We're utilizing the Wordpress Singlesite configuration in
# site_wordpress_cached.conf, since the basic rules is the same.
include /etc/nginx/vhost/site_wordpress_cached.conf;
## Below the Multisite specific stuff.
# Directive to avoid php readfile() for WordPress Multisite.
# The $root_path variable must be predefined on your vhost config file,
# use 'set' inside server{} block or 'map' before server{} block.
location ^~ /blogs.dir {
internal;
alias $root_path/wp-content/blogs.dir;
access_log off;
log_not_found off;
expires max;
}
# Directives to send expires headers for WordPress files.
location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off;
log_not_found off;
expires max;
}
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

View File

@@ -24,15 +24,18 @@ location ~ /wp-content/cache/minify.*css\.gzip$ {
add_header Content-Encoding gzip;
}
# END W3TC Minify cache
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
# END W3TC Browser Cache
# BEGIN W3TC CDN
location ~ \.(ttf|ttc|otf|eot|woff|font.css)$ {
add_header Access-Control-Allow-Origin "*";
}
# END W3TC CDN
# BEGIN W3TC Minify core
rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
set $w3tc_enc "";

View File

@@ -1,96 +0,0 @@
# WP Super Cache rules.
# Designed to be included from a 'wordpress-ms-...' configuration file.
set $skip_cache 0;
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# 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 $skip_cache 1;
set $cache_uri 'null cache';
}
# 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 $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache on WooCommerce pages
if ($request_uri ~* "(/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*)") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache for WooCommerce query string
if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache when WooCommerce cart is not empty
if ( $cookie_woocommerce_items_in_cart != "0" ) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# DO NOT CACHE Search Engine Bot crawler
if ($http_user_agent ~ "(Googlebot|Yahoo!|bingbot|MSNBot|YandexBot|Baiduspider|Alexabot|AhrefsBot)") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
## Purging FastCGI cache.
location ~ /purge(/.*) {
#access_log off;
deny all;
allow 127.0.0.1;
fastcgi_cache_purge FASTCGICACHE "$scheme$request_method$host$1";
return 301 $scheme://$server_name;
}
# START MOBILE
# Mobile browsers section to server them non-cached version. COMMENTED by default as most modern wordpress themes including twenty-eleven are responsive. Uncomment config lines in this section if you want to use a plugin like WP-Touch
# if ($http_x_wap_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
# set $cache_uri 'null cache';
#}
#END MOBILE
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args;
}
# On WP Super Cache newer version, try this one
#location / {
# try_files /wp-content/cache/supercache/$http_host/$scheme$cache_uri/index.html $uri $uri/ /index.php?$args;
#}
# Add a trailing slash to /wp-admin
location /wp-admin {
rewrite ^/wp-admin$ /wp-admin/ redirect;
}

View File

@@ -0,0 +1,30 @@
# WP Super Cache rules.
# START MOBILE
# Mobile browsers section to server them non-cached version. COMMENTED by default as most modern wordpress themes including twenty-eleven are responsive. Uncomment config lines in this section if you want to use a plugin like WP-Touch
# if ($http_x_wap_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
# set $cache_uri 'null cache';
#}
#END MOBILE
# Use cached or actual file if they exists, otherwise pass request to WordPress
#location / {
# try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args;
#}
# On WP Super Cache newer version, try this one
location / {
try_files /wp-content/cache/supercache/$http_host/$scheme$cache_uri/index.html $uri $uri/ /index.php?$args;
}

View File

@@ -1,75 +0,0 @@
## WordPress Singlesite rules with FastCGI cache enabled.
# Designed to be included in any server {} block.
## Nginx Cache, designed to be used with fastcgi_cache.conf, (optional) proxy_cache.conf
# http://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
# fastcgi_cache start
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
if ($http_x_custom_header) {
set $skip_cache 0;
}
# Skip cache for uris containing the following segments
if ($request_uri ~* "(/wp-admin|/xmlrpc.php|wp-*.php|/feed/|index.php|upgrade.php|update-core.php|memcache.php|apc.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Skip cache for logged in users or recent commenters
if ($http_cookie ~* "(comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in)") {
set $skip_cache 1;
}
# Skip cache on WooCommerce pages
if ($request_uri ~* "(/store.*|/shop.*|/cart.*|/my-account.*|/checkout.*|/addons.*)") {
set $skip_cache 1;
}
# Skip cache for WooCommerce query string
if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
}
# Skip cache when WooCommerce cart is not empty
if ( $cookie_woocommerce_items_in_cart = "1" ) {
set $skip_cache 1;
}
# DO NOT CACHE Search Engine Bot crawler
if ($http_user_agent ~ "\b(Googlebot|Yahoo|bingbot|MSNBot|YandexBot|Baiduspider|Alexabot|AhrefsBot)\b") {
set $skip_cache 1;
}
## Purging FastCGI cache.
location ~ /purge(/.*) {
access_log off;
fastcgi_cache_purge FASTCGICACHE "$scheme$request_method$host$request_uri";
return 301 $scheme://$server_name;
allow 127.0.0.1;
deny all;
}
### End of FastCGI cache settings.
## WordPress basic rules with FastCGI cache enabled.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
# Add a trailing slash to /wp-admin
location /wp-admin {
rewrite ^/wp-admin$ /wp-admin/ redirect;
}

View File

@@ -1,47 +0,0 @@
# BEGIN W3TC Minify cache
location ~ /wp-content/cache/minify.*\.js$ {
types {}
default_type application/x-javascript;
add_header Vary "Accept-Encoding";
}
location ~ /wp-content/cache/minify.*\.css$ {
types {}
default_type text/css;
add_header Vary "Accept-Encoding";
}
location ~ /wp-content/cache/minify.*js\.gzip$ {
gzip off;
types {}
default_type application/x-javascript;
add_header Vary "Accept-Encoding";
add_header Content-Encoding gzip;
}
location ~ /wp-content/cache/minify.*css\.gzip$ {
gzip off;
types {}
default_type text/css;
add_header Vary "Accept-Encoding";
add_header Content-Encoding gzip;
}
# END W3TC Minify cache
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
# END W3TC Browser Cache
# BEGIN W3TC CDN
location ~ \.(ttf|ttc|otf|eot|woff|font.css)$ {
add_header Access-Control-Allow-Origin "*";
}
# END W3TC CDN
# BEGIN W3TC Minify core
rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
set $w3tc_enc .gzip;
}
if (-f $request_filename$w3tc_enc) {
rewrite (.*) $1$w3tc_enc break;
}
rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins/w3-total-cache/pub/minify.php?test_file=$1 last;
rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1 last;
# END W3TC Minify core

View File

@@ -1,96 +0,0 @@
# WP Super Cache rules.
# Designed to be included from a 'wordpress-ms-...' configuration file.
set $skip_cache 0;
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# 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 $skip_cache 1;
set $cache_uri 'null cache';
}
# 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 $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache on WooCommerce pages
if ($request_uri ~* "(/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*)") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache for WooCommerce query string
if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# Skip cache when WooCommerce cart is not empty
if ( $cookie_woocommerce_items_in_cart != "0" ) {
set $skip_cache 1;
set $cache_uri 'null cache';
}
# DO NOT CACHE Search Engine Bot crawler
if ($http_user_agent ~ "(Googlebot|Yahoo!|bingbot|MSNBot|YandexBot|Baiduspider|Alexabot|AhrefsBot)") {
set $skip_cache 1;
set $cache_uri 'null cache';
}
## Purging FastCGI cache.
location ~ /purge(/.*) {
#access_log off;
deny all;
allow 127.0.0.1;
fastcgi_cache_purge FASTCGICACHE "$scheme$request_method$host$1";
return 301 $scheme://$server_name;
}
# START MOBILE
# Mobile browsers section to server them non-cached version. COMMENTED by default as most modern wordpress themes including twenty-eleven are responsive. Uncomment config lines in this section if you want to use a plugin like WP-Touch
# if ($http_x_wap_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_profile) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
# set $cache_uri 'null cache';
#}
#if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
# set $cache_uri 'null cache';
#}
#END MOBILE
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args;
}
# On WP Super Cache newer version, try this one
#location / {
# try_files /wp-content/cache/supercache/$http_host/$scheme$cache_uri/index.html $uri $uri/ /index.php?$args;
#}
# Add a trailing slash to /wp-admin
location /wp-admin {
rewrite ^/wp-admin$ /wp-admin/ redirect;
}