Answer the question
In order to leave comments, you need to log in
Need help in nginx. How to convert if to map?
Good day. I have the following nginx configuration:
http {
...
map_hash_bucket_size 256;
map $server_name $sites {
default 0;
include /etc/nginx/conf/doc/site_list_st.conf;
}
server {
server_name 111.111.111.111;
location / {
set $asc $sites;
if ($asc = 10) { директива on;}
if ($asc != 10) { директива off;}
}
}
}
Answer the question
In order to leave comments, you need to log in
Before the server{} section:
map $http_host $somevar {
hostnames;
host1.com "on";
host2.com "off";
default "off":
}
server {
....
set $your_param $somevar;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question