I am looking for a better way to set Environment Variable based on dynamic $host value in Nginx config. What regex expression could be used?
For example, $preferred_hostid has different value based on the $host. I can use hard code if statement to set their value. However, there are so many host values.
client1.shop.abc.com
client2.shop.abc.com
clientN.shop.abc.com
server{
listen 80 default_server;
set $preferred_hostid '.abc.com';
if ($host = 'client1.shop.abc.com'){
set $preferred_hostid '.xyz.com'
}
if ($host = 'client2.shop.abc.com'){
set $preferred_hostid '.lmn.com'
}
if ($host = 'client3.shop.abc.com'){
set $preferred_hostid '.hij.com'
}
}
What is the better way to handle this scenario? Thanks
Aucun commentaire:
Enregistrer un commentaire