/etc/nginx/conf.d/fastcgi_cache.conf
# DoS対策 limit_req_zone $binary_remote_addr zone=limit_zone:10m rate=50r/s; limit_req zone=limit_zone burst=30 nodelay; fastcgi_cache_path /var/run/nginx-fastcgi-cache levels=1:2 keys_zone=fzone:4m max_size=1024m inactive=7d; # Nginx Helper対応 fastcgi_cache_key "$mobile$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_connect_timeout 60; fastcgi_read_timeout 90; fastcgi_send_timeout 60; # upstream sent too big header while reading response header from upstream対策 fastcgi_buffer_size 128k; fastcgi_buffers 100 256k;
/etc/nginx/sites-available/example.com.conf
(略) set $mobile ''; if ($http_user_agent ~* '(DoCoMo|J-PHONE|Vodafone|MOT-|UP\.Browser|DDIPOCKET|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode|WILLCOM|SoftBank|Semulator|Vemulator|J-EMULATOR|emobile|mixi-mobile-converter)') { set $mobile '@ktai'; } if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android.+Mobile|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') { set $mobile '@mobile'; } if ($http_user_agent ~* '(iPad|Android((?!Mobile).)+$)') { set $mobile '@tablet'; } (略) location ~ .php$ { try_files $uri /index.php; #fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; # 変数$mobileをFastCGIサーバーに渡す fastcgi_param HTTP_X_UA_MOBILE $mobile; fastcgi_cache_bypass $do_not_cache; fastcgi_no_cache $do_not_cache; fastcgi_cache fzone; fastcgi_cache_valid 200 1d; fastcgi_cache_valid any 10s; } (略) ## cache purge モジュール設定 location ~ /nya-n-purge(/.*) { #allow 127.0.0.1; #allow 150.xxx.yyy.185; #deny all; fastcgi_cache_purge fzone "$mobile$scheme$request_method$host$1"; } (略)
$request_uriを$1に変更するのがポイント。
もくじ
wp-config.php
// Nginx Helper define( 'RT_WP_NGINX_HELPER_CACHE_PATH', '/var/run/nginx-fastcgi-cache');
https://ドメイン/nya-n-purge/URI
で削除出来るようになります。
Nginx Helper 設定
更新時にクリアされるようになっています。