I'm having trouble understanding nested locations in nginx. I have two locations with some configuration directives in common, so rather than repeat the directives, I'd prefer to repeat the URI using a regular-expression:
location ~ /a|/b {
location /a {
}
location /b {
}
}
However, this gives the error
nginx: [emerg] location "/a" is outside location "/a|/b" in /etc/nginx/nginx.conf:36
Without the or |
it seems okay, though.
location ~ /a {
location /a {
}
}
What am I doing wrong? Is there a better way to do this without repeating anything? Can I group locations in another way?