最近发现网上没有反代 Google 的 gstatic.com 的站点,自己又会用到相关服务,于是尝试用 Nginx 反代,参考了 ttt.tt 反代的教程,现在可以反代成功,但是每次都要重新获取很烦。反复实验了几种参数,都无法使 Nginx 告知浏览器 304 返回值。求助大家看一下,
试验链接: http://gstatic.178.re/charts/loader.js
这是 Nginx 的配置
1
longkas OP 不会贴代码 还不能编辑了
upstream gstatic { server www.gstatic.com; } proxy_buffering on; etag on; proxy_temp_file_write_size 1024k; proxy_temp_path /var/cache/nginx/temp; proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache_one:100m inactive=19d max_size=5g; server { listen 80; server_name gstatic.178.re; resolver 8.8.8.8; location / { sub_filter "www.gstatic.com" "gstatic.178.re"; sub_filter "https" "http"; sub_filter_once off; sub_filter_types *; proxy_pass_header Server; proxy_set_header Host www.gstatic.com; proxy_set_header Accept-Encoding ''; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_pass http://gstatic; proxy_cache cache_one; proxy_cache_valid 200 304 365d; proxy_cache_key $host$uri$is_args$args; proxy_cache_min_uses 1; expires max; proxy_cache_revalidate on; add_header X-Proxy-Cache $upstream_cache_status; add_header Cache-Control "public"; if_modified_since before; } } |
2
int64ago 2016-03-10 10:16:14 +08:00
|