V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hhhhhh123
V2EX  ›  程序员

请教一个 nginx http 转 http 问题

  •  
  •   hhhhhh123 · 2022-10-28 19:00:31 +08:00 · 918 次点击
    这是一个创建于 552 天前的主题,其中的信息可能已经有所发展或是发生改变。

    url: http:xxx/a/b/c/d/f/g ,http:xxx/a/b/cc/dd/ff/gg
    这两个链接我想通过匹配前面的 a/b 进行转发
    结果 a -> nginx -> 另外一个 nginx -> 第二个 nginx 的结果
    我想配置 nginx 转发 原封不动的转发 包括参数等

    code

    location /update2/assets/ {
                    return http://update.myxianlan.com/update2/assets/;
                }
    location ^~ /update2/assets/ {
                    return http://update.myxianlan.com/update2/assets/;
                }
    

    一直么有成功 哪里有问题吗? nginx->nginx2 的访问结果是 302 , 但是 nginx2 返回 403 , 应该是少了参数或者 规则写的不对。 求教~~~。

    2 条回复    2022-10-28 23:47:12 +08:00
    gstqc
        1
    gstqc  
       2022-10-28 23:10:06 +08:00 via Android
    你说的转发是什么?
    我们理解的转发是 proxy_pass
    你这不是 redirect 吗?
    9268peng
        2
    9268peng  
       2022-10-28 23:47:12 +08:00
    return 是弄出一个 302 丢给前端,你这样搞是不对的
    ps1:location 匹配是有优先级的,你这两个 location 是在一个 http 块吗?
    ps2:为什么要让 nginx 接 nginx ,意义何在?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2382 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:28 · PVG 21:28 · LAX 06:28 · JFK 09:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.