Welcome! Log In Create A New Profile

Advanced

Re: nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

Maxim Dounin
October 24, 2016 08:22AM
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
Subject Author Posted

nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

Anonymous User October 22, 2016 12:32PM

Re: nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

itpp2012 October 22, 2016 12:42PM

Re: nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

Anonymous User October 22, 2016 01:30PM

Re: nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

Maxim Dounin October 24, 2016 08:22AM

Re: nginx 1.11.5 'duplicate' map_hash_bucket_size error when geoip_country block used?

Anonymous User October 24, 2016 12:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready