V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
iiduce
V2EX  ›  NGINX

请教nginx的一个代理配置问题

  •  
  •   iiduce · 2012-08-08 13:47:07 +08:00 · 3196 次点击
    这是一个创建于 4272 天前的主题,其中的信息可能已经有所发展或是发生改变。
    对nginx的配置没有系统学过,写配置文件一般都是照猫画虎,现在有个问题搞不定,请大家帮忙。

    我现在需要实现:把我的二级域名http://abc.xxx.com通过nginx proxy绑定到http://123.yyy.com/example。 也就是访问我网站http://abc.xxx.com时,页面会显示http://123.yyy.com/example的内容,而地址栏保持http://abc.xxx.com不变。

    下面是我现在的写法,返回“server not found”:

    9 条回复    1970-01-01 08:00:00 +08:00
    honk
        1
    honk  
       2012-08-08 14:01:53 +08:00   ❤️ 1
    不用rewrite吧
    <code>
    location / {
    proxy_pass http://123.yyy.com/example/;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    </code>
    iiduce
        2
    iiduce  
    OP
       2012-08-08 14:41:04 +08:00
    @honk 我按你的写法改了,还是不行,server not found,ping也ping不通。

    域名dns需要添加什么记录么?
    honk
        3
    honk  
       2012-08-08 21:57:50 +08:00
    @iiduce

    abc.xxx.com 指向当前服务器IP了吗?

    直接访问 http://123.yyy.com/example/ 有内容吗?
    iiduce
        4
    iiduce  
    OP
       2012-08-08 22:25:22 +08:00
    @honk 指向服务器ip了。

    折腾了一天,终于找到原因了,因为托管机房的vps服务器设置了白名单,123.yyy.com无法访问。

    感谢。
    jiangle
        5
    jiangle  
       2012-08-08 23:50:40 +08:00
    楼主说的是用nginx做反向代理吧?
    citydog
        6
    citydog  
       2012-08-09 09:15:35 +08:00
    我是来看LZ头像的...
    iiduce
        7
    iiduce  
    OP
       2012-08-09 10:27:38 +08:00
    @citydog
    哈哈,你好。 其实我这个头像是会动的,可惜v2ex头像不支持gif。
    kojp
        8
    kojp  
       2012-08-09 16:48:11 +08:00
    @citydog
    @iiduce

    你们是好基友么?
    citydog
        9
    citydog  
       2012-08-09 16:48:54 +08:00
    @kojp 其实,我们互为马甲,哈哈~~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5235 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:42 · PVG 15:42 · LAX 00:42 · JFK 03:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.