囧,请问现在怎么用 nginx 反向代理 google
- 0次
- 2021-05-27 21:36:53
- idczone
试过各种配置,但一直会被重定向到ww国外服务器w.google.com.hk之类的网址上。
server {
listen 443 default ssl;
listen [::]:443;
server_name google.hahahahhahahahha.com;
/> ssl on;
ssl_certificate /cert/hahahahhahahahha.cer;
ssl_certificate_key /cert/hahahahhahahahha.pem;
location / {
proxy_redirect off;
proxy_pass https://www.google.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
/> proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.49 Safari/537.36";
/> proxy_set_header Accept-Language "zh-CN";
/> proxy_set_header Cookie "PREF=ID=xxxxxx:U=yyyyy:FF=0:LD=zh-CN:NW=1:CR=2:TM=zzzz:LM=mmmmm:GM=1:SG=1:S=-nnnnn";
/> sub_filter www.google.com g.linzhen.net;
www.google.com 替换为g.linzhen.net,否则点击某些链接会跳回到google官方。
sub_filter_once off;
}
}
这是我的配置,带HTTPS的
cat >/usr/local/nginx/conf/_proxy.inc <proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_buffer_size 64k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
proxy_cache_revalidate on;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Host \$proxy_host;
proxy_set_header Referer \$proxy_host;
proxy_set_header Cookie \$http_cookie;
proxy_pass_header Set-Cookie;
client_max_body_size 100m;
client_body_buffer_size 128k;
add_header X-Via "Proxy";
EOF
server {
resolver 8.8.8.8;
listen 80;
server_name gg.org;
location / {
subs_filter 'www.google.com' '$host';
proxy_pass http://www.google.com;
include _proxy.inc;
}
}
是自己编译的nginx么, sub_filter装了么
这种方式打开该域名后
短时间内会无法连接相应域名
给力,使用了.
subs_filter 不一定好用啊= =,有的时候会碰到google.co.jp google.com.sg之类的……
proxy_set_header Host www.google.com.hk;
server{
listen 443;
ssl on;
server_name s.galdb.net;
ssl_certificate /data/crt/s.galdb.net.crt;
ssl_certificate_key /data/crt/s.galdb.net.key;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
proxy_pass http://www.google.com.hk;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Language "zh-CN";
sub_filter www.google.com.hk s.galdb.net;
sub_filter_once off;
proxy_redirect off;
proxy_set_header Host www.google.com.hk;
}
}
用这个配置还是会被重新定向到www.google.com.hk = =
事情间隔那么久,我来填写答案吧。
proxy_redirect https://www.google.com /;
重定向到 /
哎。被网上东西骗了好久