NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
klc1989110
V2EX  ›  NGINX

nginx 如何代理部分链接到另一台机器

  •  
  •   klc1989110 · Oct 29, 2014 · 4085 views
    This topic created in 4235 days ago, the information mentioned may be changed or developed.

    有A,B两台机器,A的域名(www.a.com), B的域名为(www.b.a.com), A是还在用的老Rails项目,B是新Rails项目,现在想把指向A的几个链接(如a.com, a.com/c)转到B上, 但浏览器中地址还要显示(www.a.com/c),


    server
    {
    listen 80;
    server_name a.com;

    location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://b.a.com;
    }
    }

    这样的写法,会没法加载css,js和图片(因为发出了a.com/assets/1.js这样的请求)。
    请教nginx要怎么配置?

    4 replies    2014-10-29 16:20:23 +08:00
    loveyu
        2
    loveyu  
       Oct 29, 2014
    这个应该需要B站做下修改,ngixn只负责内容转发过来,不负责页面内部链接的处理
    klc1989110
        3
    klc1989110  
    OP
       Oct 29, 2014
    多谢2楼提供思路。
    ryd994
        4
    ryd994  
       Oct 29, 2014 via Android
    或者subsfilter把资源全换掉
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1013 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 22:13 · PVG 06:13 · LAX 15:13 · JFK 18:13
    ♥ Do have faith in what you're doing.