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

2011 年 1 月 6 日
 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)的设置。)
8323 次点击
所在节点    服务器
26 条回复
dimlau
2011 年 1 月 6 日
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 年 1 月 6 日
……呃,sever_name 那里直接写成:
server_name blog.iwinux.info;

应该就成功了吧?
yoyicue
2011 年 1 月 6 日
我是这么解决这个问题的

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 年 1 月 6 日
@dimlau

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

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

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

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

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

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

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

© 2021 V2EX