nginx url 代理服务的问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
exuxu

nginx url 代理服务的问题

  •  
  •   exuxu Jan 5, 2018 1363 views
    This topic created in 3034 days ago, the information mentioned may be changed or developed.

    我想实现访问
    ip 解析到 www.test.com

    www.test.com/sub1 www.test.com/sub2 

    nginx 用的是以下(简化)配置

    server { listen 80; server_name www.test.com; location /sub1/ { proxy_pass http://127.0.0.1:3000/; } location /sub2/ { proxy_pass http://127.0.0.1:4000/; } } 

    端口 3000 的服务全程是 http://www.test.com/sub1/xxxxxxx 为什么不可行....

    4 replies    2018-01-05 15:32:20 +08:00
    exuxu
        1
    exuxu  
    OP
       Jan 5, 2018
    ~ 沉了 ~
    h4lbhg1G
        2
    h4lbhg1G  
       Jan 5, 2018
    其实这种你可以开一个`nc -l 3000`调试下,看看打过去的是啥。因为两个都有结尾的 /,那么实际上应该相当于访问的`http://127.0.0.1:3000/xxxxxx` 。

    优雅的小尾巴:欢迎使用和 star 我的命令行工具 https://github.com/rexdf/CommandTrayHost
    exuxu
        3
    exuxu  
    OP
       Jan 5, 2018
    @h4lbhg1G 试过了其它代理服务能用,但是部署的测试服务,没法使用,测试服务会对未登录 redirect,可能是它导致的,现在是部分 header 页面加载出来了。
    h4lbhg1G
        4
    h4lbhg1G  
       Jan 5, 2018
    @exuxu 那就是是代理服务器对头或者源有检测了,如果有控制权看一下对方接的 http 头就好了。话说这样的话,你的问题的里面简化版等于啥也没说。

    如果没有控制权,那要做一系列的替换。对于重定向用 proxy_redirect,对于 css/html/js 用三方插件 subs_filter
    About     Help     Advertise     Blog     API     FAQ     Solana     1711 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 38ms UTC 16:28 PVG 00:28 LAX 09:28 JFK 12:28
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86