Welcome! Log In Create A New Profile

Advanced

Is there any harm if the map directive in nginx is repeated for the same variable name?

April 11, 2013 01:11PM
When I try it out, the definition that comes later seems to take effect. The question is, are there unintended consequences of doing this?

http {
map $http_host $a {
hostnames;
default 1;
example.com 1;
*.example.com 2;
}
map $http_host $a {
hostnames;
default 3;
example.com 3;
*.example.com 4;
}
server {
server_name example.com *.example.com
location / {
echo $a
}
}
}
Now with this configuration if I try:

curl http://example.com
3
curl http://www.example.com
4
Background: We are using this to provide an override for a map in an optional include file. So right after the map is defined, we have an include directive for *_override_map.conf. If this file exists and provides an alternate definition for the same map, then thats what gets used instead of the original map definition.
SubjectAuthorPosted

Is there any harm if the map directive in nginx is repeated for the same variable name?

jayesh_kapoorApril 11, 2013 01:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 101
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 156 on March 20, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready