Unable to configure MaxMindDB’s Apache module

apache-2.2geoiphttpd.conf

I recently installed MaxMind's MaxMindDB apache module successfully.

I added a new file called geoip.conf to /etc/httpd/conf.d/ with the following contents:

<IfModule mod_maxminddb.c>
    MaxMindDBEnable On
    MaxMindDBFile COUNTRY_DB /some/dir/GeoLite2-Country.mmdb
    MaxMindDBEnv MM_COUNTRY COUNTRY_DB/country/iso_code

    SetEnvIf MM_COUNTRY US AllowUS
    Deny from all
    Allow from env=AllowUS
</IfModule>

When running apachectl -t I get the following error:

Syntax error on line 11 of /etc/httpd/conf.d/geoip.conf:
deny not allowed here

When I commented out the "Deny from all" line I got a similar error stating that allow not allowed here

I was unable to find anything online as this module has little documentation. Does anyone know how to fix this?

Best Answer

This is simply because your Deny and Allow need to be applied within a container, either a <Directory>, <Files> or <Location> section.