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

请教 Nginx 反代 google 的问题,反代 google ip 出错

  •  
  •   ltm · 2015-06-14 19:26:16 +08:00 · 3974 次点击
    这是一个创建于 3457 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Nginx的配置如下,
    server{
    listen 80;
    server_name abc.com www.abc.com;
    return 301 https://$server_name$request_uri;
    }
    server{
    listen 443 ssl;
    ssl on;
    server_name www.abc.com abc.com;
    ssl_certificate /xxx/sslcrt/ssl.crt;
    ssl_certificate_key /xxx/sslcrt/ssl.key;
    location / {
    proxy_redirect https://www.google.com /;
    #proxy_redirect http://www.google.com /;
    proxy_pass https://216.58.219.46;
    #proxy_pass http://74.125.224.52;
    proxy_set_header Accept-Encoding "";
    proxy_set_header Accept-Language "zh-CN";
    }
    }
    使用HTTPSgoogle IP反代google,以前一直工作很好。
    昨天开始出现了https://xx.xx.xx 会重定向到www.google.com:443, 然后页面载入出错,连接被重置。
    而使用 http://xx.xx.xx形式反代时,会出现 “页面重定向循环”的错误。
    请问是什么原因,怎么解决?
    9 条回复    2015-06-15 21:52:02 +08:00
    phithon
        1
    phithon  
       2015-06-14 19:29:31 +08:00
    看你vps的位置,我把vps移到日本就会302跳转,于是我把传上游的HOST改成www.google.co.jp就好了。
    ltm
        2
    ltm  
    OP
       2015-06-14 19:36:33 +08:00
    @phithon 我的vps是美国的。
    不知道你那里用https://google ip的形式能不能打开谷歌网页。感觉谷歌好像不允许这样访问了。
    ltm
        4
    ltm  
    OP
       2015-06-14 19:56:59 +08:00
    @imWBB 谢谢了,以前没有用这个模块,是想尽量简单点配置,现在是不行了,必须得搞起复杂模式了,希望问题能够得到解决,沐浴更衣,搞起。
    yeyeye
        5
    yeyeye  
       2015-06-14 20:08:25 +08:00
    不带cookie会跳转
    chinabrowser
        6
    chinabrowser  
       2015-06-15 01:02:11 +08:00 via Android
    多个GGC IP负载均衡才行 用单个IP太久就会被识别为机器人
    chinabrowser
        7
    chinabrowser  
       2015-06-15 01:09:18 +08:00 via Android
    这是我用的配置 服务器是日本的 用的HE的IPv6

    server
    {
    listen 80;
    server_name www.example.org example.org;

    ssl on;
    ssl_certificate /root/server.crt;
    ssl_certificate_key /root/server.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;


    location / {
    proxy_redirect https://www.google.co.jp/ /;
    proxy_set_header Host "www.google.co.jp";
    proxy_set_header Accept-Encoding "";
    proxy_set_header User-Agent $http_user_agent;
    proxy_set_header Accept-Language "zh-CN";
    proxy_set_header Cookie "PREF=ID=047808f19f6com346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
    proxy_pass https://hosts;
    subs_filter www.google.co.jp example.org;
    subs_filter google.co.jp example.org;
    sub_filter_once off;
    }

    }

    server
    {
    listen 80;
    server_name www.example.org example.org;
    rewrite ^(.*) https://example.org/$1 permanent;
    }

    upstream hosts {
    server [2404:6800:4004:80c::116]:443 max_fails=3;
    server [2404:6800:4004:80c::171]:443 max_fails=3;
    server [2404:6800:4004:80c::185]:443 max_fails=3;
    server [2404:6800:4004:80c::119]:443 max_fails=3;
    server [2404:6800:4004:80c::99]:443 max_fails=3;
    server [2404:6800:4004:80c::25]:443 max_fails=3;
    server [2404:6800:4004:80c::212]:443 max_fails=3;
    server [2404:6800:4004:80c::23]:443 max_fails=3;
    server [2404:6800:4004:80c::24]:443 max_fails=3;
    server [2404:6800:4004:80c::233]:443 max_fails=3;
    server [2404:6800:4004:80c::116]:443 max_fails=3;
    server [2404:6800:4004:80c::117]:443 max_fails=3;
    server [2404:6800:4004:80c::118]:443 max_fails=3;
    server [2404:6800:4004:80c::119]:443 max_fails=3;
    server [2404:6800:4004:80c::120]:443 max_fails=3;
    server [2404:6800:4004:80c::121]:443 max_fails=3;
    server [2404:6800:4004:80c::212]:443 max_fails=3;
    server [2404:6800:4004:80c::123]:443 max_fails=3;
    server [2404:6800:4004:80c::241]:443 max_fails=3;
    server [2404:6800:4004:80c::225]:443 max_fails=3;
    server [2404:6800:4004:80c::1616]:443 max_fails=3;
    server [2404:6800:4004:80c::1741]:443 max_fails=3;
    server [2404:6800:4004:80c::1865]:443 max_fails=3;
    server [2404:6800:4004:80c::1129]:443 max_fails=3;
    server [2404:6800:4004:80c::939]:443 max_fails=3;
    server [2404:6800:4004:80c::275]:443 max_fails=3;
    server [2404:6800:4004:80c::4212]:443 max_fails=3;
    server [2404:6800:4004:80c::233]:443 max_fails=3;
    server [2404:6800:4004:80c::2422]:443 max_fails=3;
    server [2404:6800:4004:80c::2323]:443 max_fails=3;
    server [2404:6800:4004:80c::1216]:443 max_fails=3;
    server [2404:6800:4004:80c::1197]:443 max_fails=3;
    server [2404:6800:4004:80c::1108]:443 max_fails=3;
    server [2404:6800:4004:80c::11a9]:443 max_fails=3;
    server [2404:6800:4004:80c::12b0]:443 max_fails=3;
    server [2404:6800:4004:80c::12c1]:443 max_fails=3;
    server [2404:6800:4004:80c::21c2]:443 max_fails=3;
    server [2404:6800:4004:80c::1263]:443 max_fails=3;
    server [2404:6800:4004:80c::24a1]:443 max_fails=3;
    server [2404:6800:4004:80c::22a5]:443 max_fails=3;
    }
    ltm
        8
    ltm  
    OP
       2015-06-15 09:13:55 +08:00 via Android
    @chinabrowser 可能是单个IP的问题,现在我用HTTPS://xxx.xxx.xxx (Google IP )已经不能打开谷歌网页了。
    下班试一下多IP均衡负载。
    ltm
        9
    ltm  
    OP
       2015-06-15 21:52:02 +08:00
    @chinabrowser 多个IP,又加上 proxy_set_header Host "www.google.com.hk"; 这句话终于又能打开了。非常感谢。
    正在研究proxy_set_header 什么作用。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2592 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:58 · PVG 14:58 · LAX 22:58 · JFK 01:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.