Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual configuration of the path of the GeoIP2 database #22557

Open
jsabater opened this issue Sep 5, 2024 · 5 comments
Open

Allow manual configuration of the path of the GeoIP2 database #22557

jsabater opened this issue Sep 5, 2024 · 5 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. triaged

Comments

@jsabater
Copy link

jsabater commented Sep 5, 2024

When you already have the geolocation available in the system, or when you configure Matomo with enable_internet_features = 0, it would be useful to be able to configure Matomo (Settings: System: Geolocation) with the path to the database file. Matomo would, then, not worry about updates or anything, but just use it.

An example scenario would be:

  • Using Debian with the geoipupdate package, which has a cron job to update MaxMind's database periodically.
  • Disabling Matomo's internet access because it's running in an isolated environment, behind a reverse proxy.

In this scenario, when accessing the Settings: System: Geolocation menu entry, when selecting the "DBIP / GeoIP 2 (Php)" option, one would be offered different options at the bottom "Setup automatic updates of geolocation databases":

  • Let Matomo handle updates (with the current options, or similar ones).
  • Provide a path to the database, which will be updated by the system.

When using the second option, just a field with the path would be necessary:

Path to GeoIP2 database: /var/lib/GeoIP/GeoLite2-City.mmdb

I understand that this would support a DB-IP database as well.

Thanks.

@jsabater jsabater added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. To Triage An issue awaiting triage by a Matomo core team member labels Sep 5, 2024
@randy-innocraft
Copy link

Hi @jsabater,
Thank you for bringing this to our attention and for your valuable input.
Your suggestion seems like a valuable enhancement to our product.
We will forward this to our Product team for review and future consideration.
If you have any additional details or questions, please feel free to share them here.

@randy-innocraft randy-innocraft added triaged and removed To Triage An issue awaiting triage by a Matomo core team member labels Sep 5, 2024
@sgiehl
Copy link
Member

sgiehl commented Sep 9, 2024

@jsabater This should already be kind of possible if you adjust the DI config. If there is not yet a config.php in the config directory you can create one with the following content:

<?php

return [
    'path.geoip2' => '/var/lib/GeoIP/'
];

The geoip files still need to have an expected name to be picked up automatically:

public static $dbNames = array(
'loc' => array('GeoIP2-City.mmdb', 'DBIP-City.mmdb', 'DBIP-City-Lite.mmdb', 'DBIP-Country-Lite.mmdb', 'DBIP-Country.mmdb',
'dbip-city-lite-\d{4}-\d{2}.mmdb', 'GeoIP2-City-Africa.mmdb', 'GeoIP2-City-Asia-Pacific.mmdb', 'GeoIP2-City-Europe.mmdb',
'GeoIP2-City-North-America.mmdb', 'GeoIP2-City-South-America.mmdb', 'GeoIP2-Enterprise.mmdb', 'GeoIP2-Country.mmdb',
'dbip-country-lite-\d{4}-\d{2}.mmdb', 'GeoLite2-City.mmdb', 'GeoLite2-Country.mmdb', 'DBIP-Enterprise.mmdb'),
'isp' => array('GeoIP2-ISP.mmdb', 'GeoLite2-ASN.mmdb', 'DBIP-ISP.mmdb', 'GeoIP2-Enterprise.mmdb', 'DBIP-Enterprise.mmdb',
'DBIP-ASN.mmdb', 'dbip-asn-lite-\d{4}-\d{2}.mmdb'),
);

@jsabater
Copy link
Author

jsabater commented Sep 10, 2024

Hi, @sgiehl , and thanks for the indications. I think that you mean the plugins/GeoIp2/config/config.php file, which contains:

<?php

return [
    'path.geoip2' => Piwik\DI::string('{path.root}/misc/'),
    'geopip2.ispEnabled' => true
];

From your words, I understand I would change it into something like this, correct?

<?php

return [
    'path.geoip2' => '/var/lib/GeoIP/',
    'geopip2.ispEnabled' => true
];

I could add a task to my Ansible playbook to do this substitution as part of the application upgrade.

I take it that would be all? Would there be any way I could programmatically enable the Geolocation plug-in at Settings: System: Geolocation to use the DBIP / GeoIP 2 (Php) option?

@sgiehl
Copy link
Member

sgiehl commented Sep 10, 2024

No. I really meant creating a config file in config directory. That file will automatically overwrite the config in geoip plugin.
Once a geoip file is present you should be able to activate the provider in settings.

@jsabater
Copy link
Author

@sgiehl , thanks for the clarification. I'll create a config/config.php file with the content mentioned above. From your words, I take that I will have to enable the right Geolocation plug-in using the web interface, meaning there is no programmatical way to do so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. triaged
Projects
None yet
Development

No branches or pull requests

3 participants