Geo IP

Ghi chú

Tài liệu này chỉ áp dụng cho cơ sở dữ liệu On-premise.

Cài đặt

  1. Download both the GeoLite2 City and Country databases. You should end up with two files called GeoLite2-City.mmdb and GeoLite2-Country.mmdb.

  2. Move the files to the folder /usr/share/GeoIP/.

    mv ~/Downloads/GeoLite2-City.mmdb /usr/share/GeoIP/
    mv ~/Downloads/GeoLite2-Country.mmdb /usr/share/GeoIP/
    
  3. Khởi động lại máy chủ

Ghi chú

If you don’t want to locate the geoip database in /usr/share/GeoIP/, use the --geoip-city-db and --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:

./odoo-bin --geoip-city-db= ~/Downloads/GeoLite2-City.mmdb

Xem thêm

Kiểm tra vị trí địa lý GeoIP trong trang web Odoo của bạn

Chỉnh sửa trang web để bao gồm một số thông tin geo-ip như tên quốc gia của địa chỉ IP yêu cầu hiện tại. Các bước thực hiện như sau:

  1. Go to your website. Open the web page that you want to test GeoIP.

  2. Choose Customize ‣ HTML/CSS/JS Editor.

  3. Thêm đoạn XML sau vào trang:

    <h1 class="text-center" t-esc="request.geoip.country.name or 'geoip failure'"/>
    
  4. Lưu và làm mới trang.

Geo-ip sẽ hoạt động nếu bạn thấy tên quốc gia của mình được hiển thị đậm ở giữa trang.

Nếu bạn thấy “lỗi geoip” thì lỗi định vị địa lý đã xảy ra. Các nguyên nhân phổ biến là:

  1. 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.

  2. You are using a reverse-proxy (apache, nginx) in front of Odoo but didn’t start Odoo with the proxy-mode enabled. See proxy mode.

  3. Cơ sở dữ liệu GeoIP bị hỏng, bị thiếu hoặc không thể truy cập được. Trong trường hợp đó, cảnh báo đã được ghi vào nhật ký máy chủ.