Hello!
On Sat, Oct 22, 2016 at 09:30:21AM -0700, lists@ssl-mail.com wrote:
> I have a working nginx/1.11.5 instance, with this in config
>
> ...
> http(
> ...
> 134 map_hash_bucket_size 4096;
>
> ...
> )
> ...
>
> when I add geoip blocking
>
> ...
> http (
> + geoip_country /var/lib/GeoIP/GeoIP.dat;
> + map $geoip_country_code $allowed_country {
> + default yes;
> + XX no; # some country
> ...
> 134 map_hash_bucket_size 4096;
>
> ...
> )
> ...
>
> config check now reports
>
> nginx: [emerg] "map_hash_bucket_size" directive is duplicate in /etc/nginx/nginx.conf:134
>
> simply commenting out
>
> - map_hash_bucket_size 4096;
> + #map_hash_bucket_size 4096;
>
> fixes the config error.
>
> Why can't 'map_hash_bucket_size' be set in the presence of the geoip_country snippet?
>
> Config error? Bug? other?
It's not relevant to geoip_country, but rather to the map{} block
before the map_hash_bucket_size directive. Something like
map $uri $foo {}
map_hash_bucket_size 4096;
is enough to trigger the error, as the map{} block requires some
hash bucket size to be set. And if it is not set when parsing a
map{} block, it is automatically configures bucket size to a
default value. An attempt to redefine bucket size later will
trigger the error, and this is what happens with the above
configuration.
The message is a bit misleading in this particular situation
as it is a generic one. Though the fact that the configuration is
rejected is correct: nginx can't use the value specified in the
map_hash_bucket_size directive, and hence it is expected to reject
the configuration.
An obvious solution would be to specify map_hash_bucket_size
before the map{} block, i.e.:
map_hash_bucket_size 4096;
map $uri $foo {}
--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx