Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created September 6, 2012 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wokamoto/3654559 to your computer and use it in GitHub Desktop.
Save wokamoto/3654559 to your computer and use it in GitHub Desktop.
だれかさんへ(1)
server {
listen 80 default;
server_name _;
root /path/to/wordpress;
index index.html index.htm;
charset utf-8;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
include /etc/nginx/drop;
rewrite /[^/]+/wp-admin$ $scheme://$host$uri/ permanent;
#rewrite ^(.*)(index|home|default)\.html? $1 permanent;
set $mobile '';
#include /etc/nginx/mobile-detect;
location ~* ^/[^/]+/wp-(content|admin|includes) {
index index.php index.html index.htm;
if ($request_filename ~ .*\.php) {
break;
proxy_pass http://backend;
}
include /etc/nginx/expires;
}
location / {
if ($request_filename ~ .*\.php) {
break;
proxy_pass http://backend;
}
include /etc/nginx/expires;
set $do_not_cache 0;
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $do_not_cache 1;
}
if ($request_method = POST) {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_redirect off;
proxy_cache czone;
proxy_cache_key "$scheme://$host$request_uri$is_args$args$mobile";
proxy_cache_valid 200 0m;
proxy_cache_valid 404 10m;
proxy_pass http://backend;
}
include /etc/nginx/phpmyadmin;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment