第一步:网站Nginx配置文件
location /
{
proxy_cache cache_one;
proxy_cache_valid 200 304 5h;
proxy_cache_key $host$uri$is_args$args;
proxy_pass "http://www.cxyzjd.com:8080";
proxy_set_header Host www.cxyzjd.com;
proxy_set_header X-Forwarded-For $remote_addr;
add_header X-Cache "$upstream_cache_status - $upstream_response_time";
expires 1d;
}
第二步:Nginx配置文件
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /tmp/proxy_temp_dir;
proxy_cache_path /tmp/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
详细文章:http://zyan.cc/nginx_cache/
发表评论: