V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
iiduce
V2EX  ›  NGINX

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

  •  
  •   iiduce · Aug 8, 2012 · 3917 views
    This topic created in 5013 days ago, the information mentioned may be changed or developed.
    对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 replies    1970-01-01 08:00:00 +08:00
    honk
        1
    honk  
       Aug 8, 2012   ❤️ 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
       Aug 8, 2012
    @honk 我按你的写法改了,还是不行,server not found,ping也ping不通。

    域名dns需要添加什么记录么?
    honk
        3
    honk  
       Aug 8, 2012
    @iiduce

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

    直接访问 http://123.yyy.com/example/ 有内容吗?
    iiduce
        4
    iiduce  
    OP
       Aug 8, 2012
    @honk 指向服务器ip了。

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

    感谢。
    jiangle
        5
    jiangle  
       Aug 8, 2012
    楼主说的是用nginx做反向代理吧?
    citydog
        6
    citydog  
       Aug 9, 2012
    我是来看LZ头像的...
    iiduce
        7
    iiduce  
    OP
       Aug 9, 2012
    @citydog
    哈哈,你好。 其实我这个头像是会动的,可惜v2ex头像不支持gif。
    kojp
        8
    kojp  
       Aug 9, 2012
    @citydog
    @iiduce

    你们是好基友么?
    citydog
        9
    citydog  
       Aug 9, 2012
    @kojp 其实,我们互为马甲,哈哈~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   853 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 22:05 · PVG 06:05 · LAX 15:05 · JFK 18:05
    ♥ Do have faith in what you're doing.