请教问题nginx反向代理proxy

兄弟姐妹在线求帮请问一下,请教问题nginx反向代理proxy
最新回答
落寞式孤独

2024-04-16 00:06:49

下面是Nginx反向代理缓存Proxy Cache配置文件范例,仅供参考,源站点在美国,用日本的vps做Nginx代理缓存测试,实际测试效果不错. 要注意proxy_temp_path和proxy_cache_path目录本身和上级目录都要有相应权限,不然就会有生成缓存文件失败的权限错误提示. 如果需要重新生成缓存,直接把缓存目录里面的子目录都删除就可以了.
proxy_temp_path /home/ctohome/proxy_temp_dir 1 2;
proxy_cache_path /home/ctohome/proxy_cache_dir levels=1:2 keys_zone=ctohome:50m inactive=1d max_size=30g;
server {
listen 210.175.52.111:80;
server_name
www.ctohome.com
.ctohome.com;

location / {
proxy_pass
http://ctohome.com/;

proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;

client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_cache ctohome;
proxy_cache_valid 200 302 12h;
proxy_cache_valid 301 1d;
proxy_cache_valid any 1h;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}