An Ansible role to download, compile and install the latest version of MaxMind DB Apache Module on Debian and Ubuntu.
See also the geoipupdate role.
Set modmaxminddb
to true
for the tasks in this role to be run.
Front page based on country:
# {{ ansible_managed }}
<IfModule maxminddb_module>
# https://github.com/maxmind/mod_maxminddb#directives
MaxMindDBEnable On
MaxMindDBFile COUNTRY_DB /usr/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE COUNTRY_DB/country/iso_code
# UK Homepage
SetEnvIf MM_COUNTRY_CODE ^(GB|IM|JE|GG) MM_REDIRECT=uk
# North America Homepage
SetEnvIf MM_COUNTRY_CODE ^(US|MX|CA) MM_REDIRECT=na
<LocationMatch "^/$">
<If "-z %{ENV:MM_REDIRECT}">
# Global Homepage
Redirect "https://%{HTTP_HOST}/global/"
</If>
<Else>
Redirect "https://%{HTTP_HOST}/%{ENV:MM_REDIRECT}/"
</Else>
</LocationMatch>
</IfModule>
# vim: set ft=apache:
This Apache module isn't available from Debian but there is a (2018) pull request regarding Debian packaging.
Note that this uses the Debian version of libmaxminddb which is currently 1.3, rather than the latest version, however if this issue is resolved then perhaps Debian will package a newer version.
The primary URL of this repo is https://git.coop/webarch/modmaxminddb
however it is also mirrored to GitHub and available via Ansible
Galaxy.
See the GitLab releases page for details regarding each version, please use a specific version since the master branch is used for development.
Copyright 2020-2024 Chris Croome, <[email protected]>.
This role is released under the same terms as Ansible itself, the GNU GPLv3.