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

请教一个关于 nginx proxy_pass 的问题

  •  
  •   ashes1122 · Aug 11, 2020 · 2397 views
    This topic created in 2237 days ago, the information mentioned may be changed or developed.

    希望 /a 匹配到 8.8.8.8,/b/a 匹配到 9.9.9.9

    location ~/a {

      proxy_pass  http://8.8.8.8;
    

    }

    location ~/b/a {

      proxy_pass  http://9.9.9.9;
    

    }

    但是这样写第二个匹配也会匹配到 8.8.8.8 上面,求教怎么样写可以 /b/a 匹配到 9.9.9.9

    4 replies  •  2020-08-15 17:17:12 +08:00
    Cooky
        1
    Cooky  
       Aug 11, 2020 via Android   ❤️ 1
    正则吧
    M7w2kh5a58AhKlcT
        2
    M7w2kh5a58AhKlcT  
       Aug 11, 2020   ❤️ 1
    location /a {

    proxy_pass http://8.8.8.8;
    }

    location /b/a {

    proxy_pass http://9.9.9.9;
    }
    index90
        3
    index90  
       Aug 11, 2020   ❤️ 1
    正则匹配,第一个命中优先,换一下顺序就好了
    maxbon
        4
    maxbon  
       Aug 15, 2020
    加一个^
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   900 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 19:30 · PVG 03:30 · LAX 12:30 · JFK 15:30
    ♥ Do have faith in what you're doing.