首页 > nginx - 正则表达式匹配路由写法

nginx - 正则表达式匹配路由写法

想正则匹配部分路由走代理

location /chat/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_pass http://newmessage;
 }

想已/chat/开头的路由都走代理,比如 /chat/send/ 。上面的写法可以工作。

但是想添加多个匹配

location /chat/ or /a/ or /b/ {

网上查了些资料

location /(chat|a|b)/ {

这个也不能工作。


加个波浪号

location ~ /(chat|a|b)/ {
【热门文章】
【热门文章】