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

2015-06-14 19:26:16 +08:00
 ltm
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形式反代时,会出现 “页面重定向循环”的错误。
请问是什么原因,怎么解决?
3992 次点击
所在节点    NGINX
9 条回复
phithon
2015-06-14 19:29:31 +08:00
看你vps的位置,我把vps移到日本就会302跳转,于是我把传上游的HOST改成www.google.co.jp就好了。
ltm
2015-06-14 19:36:33 +08:00
@phithon 我的vps是美国的。
不知道你那里用https://google ip的形式能不能打开谷歌网页。感觉谷歌好像不允许这样访问了。
imWBB
2015-06-14 19:45:46 +08:00
ltm
2015-06-14 19:56:59 +08:00
@imWBB 谢谢了,以前没有用这个模块,是想尽量简单点配置,现在是不行了,必须得搞起复杂模式了,希望问题能够得到解决,沐浴更衣,搞起。
yeyeye
2015-06-14 20:08:25 +08:00
不带cookie会跳转
chinabrowser
2015-06-15 01:02:11 +08:00
多个GGC IP负载均衡才行 用单个IP太久就会被识别为机器人
chinabrowser
2015-06-15 01:09:18 +08:00
这是我用的配置 服务器是日本的 用的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
2015-06-15 09:13:55 +08:00
@chinabrowser 可能是单个IP的问题,现在我用HTTPS://xxx.xxx.xxx (Google IP )已经不能打开谷歌网页了。
下班试一下多IP均衡负载。
ltm
2015-06-15 21:52:02 +08:00
@chinabrowser 多个IP,又加上 proxy_set_header Host "www.google.com.hk"; 这句话终于又能打开了。非常感谢。
正在研究proxy_set_header 什么作用。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/198497

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX