iwinux
V2EX  ›  服务器

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

  •  
  •   iwinux · Jan 6, 2011 · 8032 views
    This topic created in 5632 days ago, the information mentioned may be changed or developed.
    我参照 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 replies    1970-01-01 08:00:00 +08:00
    dimlau
        1
    dimlau  
       Jan 6, 2011
    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  
       Jan 6, 2011
    ……呃,sever_name 那里直接写成:
    server_name blog.iwinux.info;

    应该就成功了吧?
    yoyicue
        3
    yoyicue  
       Jan 6, 2011
    我是这么解决这个问题的

    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
       Jan 6, 2011
    @dimlau

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

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

    我按这种方法,只能实现A记录的绑定,一个vps一个域名,太浪费了
    laihj
        16
    laihj  
       Feb 23, 2011
    例如我的域名是diggdb4.us
    配置后ping ghs.diggdb4.us还是404
    ghs.diggdb4.us在godaddy那边需要什么配置吗?
    TheOnly92
        17
    TheOnly92  
       Feb 23, 2011
    godaddy 要增加一个 A 设置。
    laihj
        18
    laihj  
       Feb 23, 2011
    diggdb4.us和ghs.diggdb4.us指向同一个ip?
    fanzeyi
        19
    fanzeyi  
       May 12, 2011
    @yoyicue 额 我按照你的方案写的这个.. 但是nginx一直提示 The requested URL / was not found on this server. ....
    http://gist.github.com/018b74b7af8b5ae54667
    fanzeyi
        20
    fanzeyi  
       May 12, 2011
    咦 为什么显示的gist不对... http://gist.github.com/018b74b7af8b5ae54667
    fanzeyi
        21
    fanzeyi  
       May 12, 2011
    召唤 @livid ... 使用 Private 的时候贴的地址无法被正确识别....

    http://gist.github.com/967864
    yoyicue
        22
    yoyicue  
       May 12, 2011
    @fanzeyi 你把全部贴出来~
    fanzeyi
        23
    fanzeyi  
       May 12, 2011
    @yoyicue 这个就是全部啊.....
    fanzeyi
        24
    fanzeyi  
       May 12, 2011
    @fanzeyi 好吧 sorry 我傻逼了。。。 是我 appspot 上面没写东西...
    yoyicue
        25
    yoyicue  
       May 12, 2011
    @fanzeyi .... 我完全刚才没有看到gist.
    nonozone
        26
    nonozone  
       Nov 30, 2012
    呃,找到这个帖子,顺便请教下,我按照如上说明整了一个域名ghs.abc.com,直接访问ghs.abc.com出现google的404,这个应该代表ghs代理成功吧,然后我又整了个域名xyz.com cname到ghs.abc.com,为什么变成我自己服务器的默认站点了,而不是到blogger?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3404 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    ♥ Do have faith in what you're doing.