› 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 · 2525 views
    This topic created in 2278 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
    Cooky
    Aug 11, 2020 via Android❤️1
    1
    正则吧
    M7w2kh5a58AhKlcT
    M7w2kh5a58AhKlcT
    Aug 11, 2020❤️1
    2
    location /a {

    proxy_pass http://8.8.8.8;
    }

    location /b/a {

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