iwinux
V2EX  ›  服务器

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

  •  
  •   iwinux · Jan 6, 2011 · 8444 views
    This topic created in 5798 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
    dimlau
    Jan 6, 2011
    1
    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
    dimlau
    Jan 6, 2011
    2
    ……呃,sever_name 那里直接写成:
    server_name blog.iwinux.info;

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

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

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

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

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

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