Matching multiple endpoints in location of nginx.conf

Igor Sysoev igor at sysoev.ru
Mon Nov 24 06:12:18 UTC 2014


On 23 Nov 2014, at 23:51, keeyong <nginx-forum at nginx.us> wrote:

> I can't really test this easily so I am asking instead. I have this location
> statement in my nginx.conf:
> 
>        location ~* ^/(api/abcd)/ {
>            ...
>        }
> 
> Now I want to match against "api/efgh". Then the regex should be something
> like this?
> 
>        location ~* ^/(api/(abcd|efgh))/ {
>            ...
>        }
> 
> OR
> 
>        location ~* ^/api/(abcd|efgh)/ {
>            ...
>        }
> 
> OR
> 
> something else?

location /api/abcd/ {
    [ some configuration ]
}

location /api/efgh/ {
    [ and yes, copy paste the configuration above ]
}


-- 
Igor Sysoev
http://nginx.com



More information about the nginx mailing list