[IMP] core: additionnal country db for geoip

closes odoo/documentation#2151

Task: 2848206
Related: odoo/enterprise#27399
Related: odoo/odoo#91337
Signed-off-by: Julien Castiaux <juc@odoo.com>
Co-authored-by: Lau-Odoo <46811180+Lau-Odoo@users.noreply.github.com>
Co-authored-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Julien Castiaux 2022-05-16 14:56:52 +00:00
parent 26364227a6
commit ca445c86c8
3 changed files with 38 additions and 38 deletions

View File

@ -5,60 +5,56 @@ Geo IP Installation (On-Premises Database)
Installation
============
.. warning::
Please note that the installation depends on your computer's operating system and distribution.
We will assume that a Linux operating system is being used.
#. Download both the GeoLite2 City and Country
`databases <https://dev.maxmind.com/geoip/geoip2/geolite2/>`_. You should end up with two files
called :file:`GeoLite2-City.mmdb` and :file:`GeoLite2-Country.mmdb`.
#. Install `geoip2 <https://pypi.org/project/geoip2/>`__ Python library
.. code-block:: bash
#. Move the files to the folder :file:`/usr/share/GeoIP/`.
pip install geoip2
.. code-block:: bash
#. Download the `GeoLite2 City database <https://dev.maxmind.com/geoip/geoip2/geolite2/>`_. You
should end up with a file called ``GeoLite2-City.mmdb``
#. Move the file to the folder ``/usr/share/GeoIP/``
.. code-block:: bash
mv ~/Downloads/GeoLite2-City.mmdb /usr/share/GeoIP/
mv ~/Downloads/GeoLite2-City.mmdb /usr/share/GeoIP/
mv ~/Downloads/GeoLite2-Country.mmdb /usr/share/GeoIP/
#. Restart the server
.. note::
If you can't/don't want to locate the geoip database in ``/usr/share/GeoIP/``, you can use the
``--geoip-db`` option of the Odoo command line interface. This option takes the absolute path to
the GeoIP database file and uses it as the GeoIP database. For example:
If you don't want to locate the geoip database in :file:`/usr/share/GeoIP/`, use the
:option:`--geoip-city-db <odoo-bin --geoip-city-db>` and
:option:`--geoip-country-db <odoo-bin --geoip-country-db>` options of the Odoo command line
interface. These options take the absolute path to the GeoIP database file and use it as the
GeoIP database. For example:
.. code-block:: bash
./odoo-bin --geoip-db= ~/Downloads/GeoLite2-City.mmdb
./odoo-bin --geoip-city-db= ~/Downloads/GeoLite2-City.mmdb
.. seealso::
- :doc:`CLI documentation </developer/cli>`.
.. warning::
``GeoIP`` Python library can also be used. However this version is discontinued since January
1. See `GeoLite Legacy databases are now discontinued
<https://support.maxmind.com/geolite-legacy-discontinuation-notice/>`_
Test GeoIP Geolocation In Odoo Website
======================================
How To Test GeoIP Geolocation In Your Odoo Website
==================================================
1. Go to your website. Open the web page that you want to test ``GeoIP``.
2. Choose :menuselection:`Customize --> HTML/CSS/JS Editor`.
3. Add the following piece of XML in the page :
Edit a web page to include some geo-ip information such as the country name of the current
request IP address. To do so:
.. code-block:: xml
#. Go to your website. Open the web page that you want to test ``GeoIP``.
#. Choose :menuselection:`Customize --> HTML/CSS/JS Editor`.
#. Add the following piece of XML in the page :
<h1 class="text-center" t-esc="request.session.get('geoip')"/>
.. code-block:: xml
You should end up with a dictionary indicating the location of the IP address.
<h1 class="text-center" t-esc="request.geoip.country.name or 'geoip failure'"/>
.. image:: on-premise_geo-ip-installation/on-premise_geo-ip-installation01.png
:align: center
#. Save and refresh the page.
.. note::
If the curly braces are empty ``{}``, it can be for any of the following reasons :
Geo-ip is working if you read your country name displayed in bold in the middle of the page.
- The browsing IP address is the localhost (``127.0.0.1``) or a local area network one (``192.168.*.*``)
- If a reversed proxy is used, make sure to configure it correctly. See :option:`proxy mode <odoo-bin --proxy-mode>`
- ``geoip2`` is not installed or the GeoIP database file wasn't found
- The GeoIP database was unable to resolve the given IP address
In case you read "**geoip failure**" instead then the geolocalization failed. The common causes are:
#. The browsing IP address is the localhost (``127.0.0.1``) or a local area network one. If you
don't know, you can access your website using mobile data.
#. You are using a reverse-proxy (apache, nginx) in front of Odoo but didn't start Odoo with the
proxy-mode enabled. See :option:`proxy mode <odoo-bin --proxy-mode>`.
#. The GeoIP database is corrupt, missing or unaccessible. In such case a warning was logged in the
server logs.

View File

@ -137,9 +137,13 @@ Running the server
stops the server after its initialization.
.. option:: --geoip-db <path>
.. option:: --geoip-city-db <path>
Absolute path to the GeoIP database file.
Absolute path to the GeoIP City database file.
.. option:: --geoip-country-db <path>
Absolute path to the GeoIP Country database file.
.. _reference/cmdline/testing: