Created
October 4, 2012 15:50
-
-
Save wokamoto/3834531 to your computer and use it in GitHub Desktop.
網元用 サブドメイン型マルチサイト WP nginx 設定例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name example.com *.example.com; | |
root /var/www/vhosts/example.com; | |
index index.html index.htm; | |
charset utf-8; | |
access_log /var/log/nginx/example.com.access.log main; | |
error_log /var/log/nginx/example.com.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 ~* ^/files/.*$ { | |
proxy_redirect off; | |
proxy_cache czone; | |
proxy_cache_key "$scheme://$host$request_uri$is_args$args"; | |
proxy_cache_valid 200 86400m; | |
proxy_cache_valid 404 10m; | |
proxy_pass http://backend; | |
} | |
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