- Install the GeoIP2 Python libraries
pip3 install geoip2
- Install the Python flask framework
pip3 install flask
- Install Gunicorn to run flask as a service
pip3 install gunicorn
- Clone the Git to target directory
git clone https://github.com/Know1/iplookup.git /opt/geoip2
- Run it Interactively as a test
cd /opt/geoip2
gunicorn --pid /run/geoip2.pid -b localhost:5001 iplookup
You should now be able to connect to http://localhost:5001
Optional setup:
- Set IPLookup to run as a service
cp /opt/geoip2/iplookup.service.sample /etc/systemd/system/geoip2.service
systemctl daemon-reload
systemctl enable iplookup.service
systemctl start iplookup.service
- Configure Apache2 as a reverse proxy to the service
cp /opt/geoip2/iplookup.conf.sample /etc/apache2/sites-available/iplookup.conf
a2ensite iplookup
systemctl reload apache2
- Refresh the Maxmind GeoIP DBs regularly
apt install geoipupdate
cp /opt/geoip2/GeoIP.conf.sample /etc/GeoIP.conf
cp /opt/geoip2/geoipupdate.crond.sample /etc/cron.d/geoipupdate