multiple locations to same block

25 views
Skip to first unread message

Alexander Gray II

unread,
Jul 21, 2016, 11:05:44 AM7/21/16
to openresty-en
I have around 20 location that do the same thing.
location /a/ {
...
}
location /b/ {
...
}
etc etc

Is there way to have them in a single block, something like this:
location /a/,/b/,/c/,/d/ {
...
}
or suck them up from a file?
location from_file(myfile){
}

Sorry if this a newbie question.  I'm just getting my feet wet with this.

Robert Paprocki

unread,
Jul 21, 2016, 11:09:48 AM7/21/16
to openre...@googlegroups.com
Location blocks can be defined using a regular expression, so you could have something like:

location ~* ^/(a|b|c)$ {
...
}

Provided of course that you properly define your regex for your context and use case.
Have a look at http://nginx.org/en/docs/http/request_processing.html as well as
http://nginx.org/en/docs/http/ngx_http_core_module.html#location.

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Gray II

unread,
Jul 21, 2016, 11:22:25 AM7/21/16
to openresty-en, rob...@cryptobells.com
Awesome! Thanks!
Reply all
Reply to author
Forward
0 new messages