Nginx反向代理 帶緩存機制的反向代理
#vim /usr/local/nginx/conf/nginx/conf
..............
http {
......
proxy_cache_path /var/www/cache levels=1:2 keys_zone=mycache:20m max_size=2048m inactive=60m;
proxy_temp_path /www/cache/tmp;
......
server {
listen 80;
server_name www.andy.com;
location / {
proxy_pass http://127.0.0.1/;
proxy_cache mycache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
#重啟nginx服務#service nginx restart *