Answer the question
In order to leave comments, you need to log in
Is it possible to set a variable in Nginx without an IF block?
I need to get the subdomain for further use in the config. Now I'm doing this:
set $subdomain "";
if ($host ~ "^(.*)\.site\.com\.local$") {
set $subdomain $1;
}
Answer the question
In order to leave comments, you need to log in
nginx.org/ru/docs/http/ngx_http_map_module.html
map $host $subdomain {
default "";
~^(.*)\.site\.com\.local$ $1;
}
server_name ~^(?<subdomain>.*)\.site\.com\.local$;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question