дружить с ним надо правильно -) :
proxy_cache_path /var/lib/nginx/tmp/proxy levels=1:2 keys_zone=ws:100m max_size=1024m inactive=5 d;
proxy_cache_path /var/lib/nginx/tmp/proxy levels=1:2 keys_zone=media:100m max_size=1024m inactive=5d;
proxy_temp_path /var/lib/nginx/tmp/proxy_tmp 1 2;
proxy_buffering on;
proxy_cache_min_uses 1;
proxy_cache_valid 200 10m;
proxy_cache_valid 302 304 10m;
proxy_cache_valid 404 502 1m;
proxy_cache_valid 503 4s;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_pass_header Cookie;
proxy_pass_header Set-Cookie;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
##keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml application/x-pointplus application/x-javascript text/css;
gzip_comp_level 3;
#
server {
listen x.x.x.x:80;
server_name ws.com;
server_name_in_redirect off;
set $media_ 0;
# set headers for the backend
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Host $http_host;
proxy_set_header X-URI $uri;
proxy_set_header X-ARGS $args;
proxy_set_header Refer $http_refer;
# pass headers from backend to client
proxy_pass_header Cookie;
proxy_pass_header Set-Cookie;
client_max_body_size 40m;
client_body_buffer_size 256k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 8k;
proxy_buffers 8 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;
# capture cookies for use in the cache key
set $wordpress_logged_in "";
set $comment_author_email "";
set $comment_author "";
if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
set $wordpress_logged_in wordpress_logged_in_$1;
}
if ($http_cookie ~* "comment_author_email_[^=]*=([^;]+)(;|$)") {
set $comment_author_email comment_author_email_$1;
}
if ($http_cookie ~* "comment_author_[^=]*=([^;]+)(;|$)") {
set $comment_author comment_author_$1;
}
# set the proxy cache key
set $my_cache_key $scheme$request_method$host$uri$is_args$args$wordpress_logged_in$comment_author_email$comment_author;
###Static files location
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|html|flv)$ {
root /srv/Web/www.ws.com/;
proxy_pass http://127.0.0.1:80;
proxy_redirect off;
proxy_cache media;
proxy_cache_key $my_cache_key;
proxy_cache_valid 200 302 304 30d;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
set $media_ 1;
expires 14d;
}
location /wp-admin {
proxy_pass http://127.0.0.1:80;
proxy_redirect off;
}
location /wp-login.php {
proxy_pass http://127.0.0.1:80;
proxy_redirect off;
}
location / {
proxy_pass http://127.0.0.1/;
proxy_redirect off;
proxy_cache ws;
proxy_cache_key $my_cache_key;
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
access_log /srv/Web/www.ws.com/_NG_local.log;
set $media_ 0;
}
}
#end server