在反向代理上做静态文件加速,不用到主服务器上面查询文件:
location ~ "\.(swf|js|ico|gif|jpg|png|css|html|htm)$" {
root /var/cache/nginx/$host;
set $original_uri $uri;
error_page 404 = /fetch;
}
location /fetch {
internal;
proxy_pass http://202.101.000.111:80;
proxy_store /var/cache/nginx/$host${original_uri};
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}