V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
longkas
V2EX  ›  NGINX

Nginx 反代无法返回 304,求助

  •  1
     
  •   longkas · 2016-03-10 09:48:33 +08:00 · 3421 次点击
    这是一个创建于 2961 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近发现网上没有反代 Google 的 gstatic.com 的站点,自己又会用到相关服务,于是尝试用 Nginx 反代,参考了 ttt.tt 反代的教程,现在可以反代成功,但是每次都要重新获取很烦。反复实验了几种参数,都无法使 Nginx 告知浏览器 304 返回值。求助大家看一下,
    试验链接: http://gstatic.178.re/charts/loader.js
    这是 Nginx 的配置

    https://gist.github.com/Archieeeeee/b27a46b62775fb188c07

    2 条回复    2016-03-10 10:16:14 +08:00
    longkas
        1
    longkas  
    OP
       2016-03-10 10:00:35 +08:00
    不会贴代码 还不能编辑了
    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;
    }


    }
    int64ago
        2
    int64ago  
       2016-03-10 10:16:14 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5288 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:52 · PVG 15:52 · LAX 00:52 · JFK 03:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.