请教nginx ghs域名反向代理的设置

2011-01-06 20:34:16 +08:00
 iwinux
我参照 you8g.com 的方法,做了以下设置:
1. Google Apps 里绑定 appspot 的 app 到 blog.iwinux.info
2. blog.iwinux.info 指向我的VPS
3. VPS上的 nginx 这样设置:

http://gist.github.com/767827

完成以上步骤并确定DNS记录生效之后,我访问 blog.iwinux.info 出现 Google 的 404 页面。

请问我做错了哪一步?

(我Google到的设置方法都大同小异,而 nginx 的官方文档讲的都是针对特定应用(比如jetty)的设置。)
7141 次点击
所在节点    服务器
26 条回复
dimlau
2011-01-06 20:49:43 +08:00
upstream ghs {
ip_hash;
server ghs.google.com;
}
server
{
listen 80;
server_name ghs.whatever.name;

location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_pass http://ghs;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect false;
}

}


然后,你的 blog.iwinux.info 应该设置 CNAME 到 ghs.whatever.name 才对。
dimlau
2011-01-06 20:51:41 +08:00
……呃,sever_name 那里直接写成:
server_name blog.iwinux.info;

应该就成功了吧?
yoyicue
2011-01-06 20:59:24 +08:00
我是这么解决这个问题的

GAE不绑定域,直接
proxy_pass http://mygae.appspot.com;
proxy_set_header Host "mygae.appspot.com";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
iwinux
2011-01-06 21:00:58 +08:00
@dimlau

配置文件照你写的改了,
server_name 也改成 blog.iwinux.info

重启nginx后还是 404 = =
iwinux
2011-01-06 21:02:50 +08:00
@yoyicue 其实我是想实现类似 you8g 的功能,可以动态添加想转发的域名...
yoyicue
2011-01-06 21:05:43 +08:00
@iwinux 我觉得问题在于 proxy_set_header Host $host;
iwinux
2011-01-06 21:07:51 +08:00
召唤 @gonbo O_O
iwinux
2011-01-07 00:03:53 +08:00
尚未解决 = =
gonbo
2011-01-07 00:21:58 +08:00
#you8g 是通过生成nginx配置文件,生成后同步nginx配置文件,然后nginx reload,来解决这个问题的。
linsk
2011-01-07 00:30:47 +08:00
手机版没有收藏功能,mark 不方便
Platinum
2011-01-07 00:45:51 +08:00
server {
listen 80;
server_name blog.iwinux.info;
location / {
proxy_set_header Host yourname.appspot.com;
proxy_pass http://ghs.google.com;
}
}
iwinux
2011-01-07 00:46:35 +08:00
@gonbo 那配置文件是怎么写的呢?我试了很多种配置写法,目前只有 @yoyicue 给出的这个是正常工作的……
iwinux
2011-01-07 17:29:53 +08:00
最后我还是用了 @Platinum 和 @yoyicue 的方法
不过还是很好奇 you8g 的配置是怎么写的……
gonbo
2011-01-07 21:23:53 +08:00
都差不多,只是you8g的需要支持大量域名和支持cache
laihj
2011-02-23 16:52:09 +08:00
那怎么实现多个域名通过ghs.xxx.com一起绑定呢

我按这种方法,只能实现A记录的绑定,一个vps一个域名,太浪费了
laihj
2011-02-23 16:54:16 +08:00
例如我的域名是diggdb4.us
配置后ping ghs.diggdb4.us还是404
ghs.diggdb4.us在godaddy那边需要什么配置吗?
TheOnly92
2011-02-23 17:16:32 +08:00
godaddy 要增加一个 A 设置。
laihj
2011-02-23 17:36:45 +08:00
diggdb4.us和ghs.diggdb4.us指向同一个ip?
fanzeyi
2011-05-12 11:01:05 +08:00
@yoyicue 额 我按照你的方案写的这个.. 但是nginx一直提示 The requested URL / was not found on this server. ....
http://gist.github.com/018b74b7af8b5ae54667
fanzeyi
2011-05-12 11:01:59 +08:00
咦 为什么显示的gist不对... http://gist.github.com/018b74b7af8b5ae54667

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

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

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

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

© 2021 V2EX