V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iwinux
V2EX  ›  服务器

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

  •  
  •   iwinux · 2011-01-06 20:34:16 +08:00 · 7132 次点击
    这是一个创建于 4881 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我参照 you8g.com 的方法,做了以下设置:
    1. Google Apps 里绑定 appspot 的 app 到 blog.iwinux.info
    2. blog.iwinux.info 指向我的VPS
    3. VPS上的 nginx 这样设置:



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

    请问我做错了哪一步?

    (我Google到的设置方法都大同小异,而 nginx 的官方文档讲的都是针对特定应用(比如jetty)的设置。)
    26 条回复    1970-01-01 08:00:00 +08:00
    dimlau
        1
    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
        2
    dimlau  
       2011-01-06 20:51:41 +08:00
    ……呃,sever_name 那里直接写成:
    server_name blog.iwinux.info;

    应该就成功了吧?
    yoyicue
        3
    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
        4
    iwinux  
    OP
       2011-01-06 21:00:58 +08:00
    @dimlau

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

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

    我按这种方法,只能实现A记录的绑定,一个vps一个域名,太浪费了
    laihj
        16
    laihj  
       2011-02-23 16:54:16 +08:00
    例如我的域名是diggdb4.us
    配置后ping ghs.diggdb4.us还是404
    ghs.diggdb4.us在godaddy那边需要什么配置吗?
    TheOnly92
        17
    TheOnly92  
       2011-02-23 17:16:32 +08:00
    godaddy 要增加一个 A 设置。
    laihj
        18
    laihj  
       2011-02-23 17:36:45 +08:00
    diggdb4.us和ghs.diggdb4.us指向同一个ip?
    fanzeyi
        19
    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
        20
    fanzeyi  
       2011-05-12 11:01:59 +08:00
    咦 为什么显示的gist不对... http://gist.github.com/018b74b7af8b5ae54667
    fanzeyi
        21
    fanzeyi  
       2011-05-12 11:03:15 +08:00
    召唤 @livid ... 使用 Private 的时候贴的地址无法被正确识别....

    http://gist.github.com/967864
    yoyicue
        22
    yoyicue  
       2011-05-12 11:09:19 +08:00
    @fanzeyi 你把全部贴出来~
    fanzeyi
        23
    fanzeyi  
       2011-05-12 11:12:38 +08:00
    @yoyicue 这个就是全部啊.....
    fanzeyi
        24
    fanzeyi  
       2011-05-12 11:14:10 +08:00
    @fanzeyi 好吧 sorry 我傻逼了。。。 是我 appspot 上面没写东西...
    yoyicue
        25
    yoyicue  
       2011-05-12 11:15:34 +08:00
    @fanzeyi .... 我完全刚才没有看到gist.
    nonozone
        26
    nonozone  
       2012-11-30 16:18:34 +08:00
    呃,找到这个帖子,顺便请教下,我按照如上说明整了一个域名ghs.abc.com,直接访问ghs.abc.com出现google的404,这个应该代表ghs代理成功吧,然后我又整了个域名xyz.com cname到ghs.abc.com,为什么变成我自己服务器的默认站点了,而不是到blogger?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1366 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 17:41 · PVG 01:41 · LAX 10:41 · JFK 13:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.