分享一下我的 Nginx 反向代理 Google 以及草榴等的参数配置

2014-08-04 13:21:57 +08:00
 anjunecha
刚刚看到一个帖子提到了那个 wen.lu ,想着就把自己的反向代理配置分享一下,因为网上的教程大多是错的。下面的参数配置只需把xxx.xxx改为你自己的域名以及修改一下你的SSL路径就可以了。

Nginx 反代 Google配置如下

server
{
listen 443;
server_name xxx.xxx;
ssl on;
ssl_certificate /usr/local/nginx/xxx.crt;#这里改为你自己的证书路径
ssl_certificate_key /usr/local/xxx.key;#这里改为你自己的密钥路径

location / {
proxy_redirect http://www.google.com/ /;
proxy_cookie_domain google.com xxx.xxx;
proxy_pass http://173.194.127.48;
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=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
sub_filter www.google.com xxx.xxx;
sub_filter_once off;
}
}

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

#把所有的xxx.xxx改为你自己的域名
54286 次点击
所在节点    分享创造
82 条回复
anjunecha
2014-08-04 13:33:33 +08:00
很神奇为何不能添加append....那就贴在回复里面好了

Nginx 反代 Google Scholar 的配置如下:

server
{
listen 443;
server_name xxx.xxx;

ssl on;
ssl_certificate /usr/local/nginx/ssl.crt;
ssl_certificate_key /usr/local/nginx/ssl.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;


location / {
proxy_redirect http://scholar.google.com/ /;
proxy_set_header Host "scholar.google.com";
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=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
proxy_pass http://scholar.google.com;
sub_filter scholar.google.com xxx.xxx;
sub_filter_once off;
}

}

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

#把所有的xxx.xxx改为你自己的域名
anjunecha
2014-08-04 13:34:40 +08:00
Nginx 反代草榴论坛 的配置如下:

server
{
listen 80;
server_name xxx.xxx;

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://184.154.128.246/;
}

}

#把所有的xxx.xxx改为你自己的域名即可
edwinlai
2014-08-04 13:49:39 +08:00
wen.lu 不能新标签打开页面, 你这个google反代可以吗
anjunecha
2014-08-04 13:50:27 +08:00
@edwinlai 可以
anjunecha
2014-08-04 13:50:47 +08:00
@edwinlai 他主要是少了一行代码
anjunecha
2014-08-04 13:53:17 +08:00
终于可以append了,那我就把前两条回复贴到append里面,好查看
GhostFlying
2014-08-04 13:55:22 +08:00
收下,扔到自己的vps上去
edwinlai
2014-08-04 13:57:33 +08:00
测试不行,不知道是不是因为没启用ssl原因,就用80
anjunecha
2014-08-04 14:01:05 +08:00
@edwinlai 不使用ssl加密反代google的配置是这样的

server {
listen 80;
server_name xxx.xxx;

location / {
proxy_redirect http://www.google.com/ /;
proxy_cookie_domain google.com xxx.xxx;
proxy_pass http://173.194.127.48;
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=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
sub_filter www.google.com xxx.xxx;
sub_filter_once off;
}
}
BOOM
2014-08-04 14:01:06 +08:00
不错。amh可以直接配置反向代理就可以了。。
不过话说,https://github.com/greatfire/freegoogle 也算是反代么。。
另一个类似wen.lu的反代——www.tmd123.com
anjunecha
2014-08-04 14:03:43 +08:00
@BOOM www.tmd123.com 像这样的已经不是单纯的直接反向代理,这应该是调用了 Google 的 API
GhostFlying
2014-08-04 14:04:08 +08:00
@anjunecha 明文过墙风险略大吧。。
adoraj
2014-08-04 14:04:20 +08:00
看来Nginx真是好东西啊。
lovetest
2014-08-04 14:05:30 +08:00
@BOOM 这个不是真正的google吧
anjunecha
2014-08-04 14:05:51 +08:00
@GhostFlying SSL 加密之后问题不大,只是流量不能太大。。。
datou
2014-08-04 14:09:16 +08:00
能反代youtube吗?
GhostFlying
2014-08-04 14:09:32 +08:00
@anjunecha 嗯,我去自己签个证书部署下
anjunecha
2014-08-04 14:12:32 +08:00
@datou 没有尝试过,不过我估计Youtube的视频内容是分发的,很难实现反代
O21
2014-08-04 14:16:43 +08:00
这样可以么?

server
{
listen 80;
server_name xxx.net;

location / {
proxy_pass http://twitter.com/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
anjunecha
2014-08-04 14:21:52 +08:00
@O21 80端口没法访问twitter吧,twitter的话用它的API 来做也挺好的

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

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

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

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

© 2021 V2EX