[Geändert - Ich weiß gar nicht warum ich das eigentlich auf engl. gepostet habe hier die deutsche Version:]
German (for english see below)
Hallo alle zusammen,
erst einmal Danke dass Ihr so lieb seid mein Problem anzuschauen.
Ich betreibe einen WP Blog auf einem dedicated server. dieser wird von unserem load balancer (nginx) per proxy_pass aufgerufen. Mein Problem ist dass ich gerne allen Statischen Content direkt vom NginX ausliefern lassen möchte. Nicht aber den Content vom Blog, da dieser sich ja ständig ändert. Wie kann ich bloß dem NGINX sagen dass er zwar alle statischen Dateien ausliefern muss aber nicht wenn der blog aufgerufen wurde ("/blog/" in der URL) Unten meine NGINX Config.
English:
Hello all,
first of all thanks for looking into this. I have the following problem.
Wordpress is running on a dedicated server only for wordpress out application is running on other application servers. to handle the load we have also a load balancer working. To deliver the load as fast as possible we deliver static content directly via the lb (nginx). Here my question:
1) the load balancer gets the request
2a) if its static conent is delivers it directly
2b) if its application relevant it forwards the request to the tomcats on the application servers
2c) if its blog content (location /blog) nginx get the blog information via proxy pass from the dedicated blog server.
My Problem is now that in case of 2c) i dont want to deliver the static content from the load balancer directly (because its not there).. for all /blog/ content nginx should get ALL data via proxy_pass from wordpress..
Any ideas?
here is my current server configuration for nginx (that is not working for /blog/ :) :
if ($request_uri ~* "/blog/") {
location ~* ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
expires max;
root /var/www/static;
}
location ~* ^.+.(css|txt|js)$ {
access_log off;
expires 15d;
root /var/www/static;
}
}
location /blog/ {
# If logged in, don't cache.
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $do_not_cache 1;
}
proxy_cache_key "$scheme://$host$request_uri $do_not_cache";
proxy_pass_header Set-Cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sub_filter_once off;
sub_filter 'subdomainForBlog' 'MainDomain/blog';
proxy_pass http://subdomainForBlog;
}
Alles anzeigen