IP Geolocation Database

OpenResty Edge product integrates support for various IP geolocation databases, including MaxMind Enterprise, MaxMind Lite, ipip.net, and others. These databases provide powerful geolocation-related functionality support for the OpenResty Edge product.

Importance of IP Geolocation Database

The integration of IP geolocation databases enables OpenResty Edge to provide the following key features:

  1. Enhanced Log Information: In pages containing client IP information such as Error Logs and WAF Logs, the system automatically parses the geolocation information of IP addresses, providing more detailed access source data.

  2. Fine-grained Rule Configuration: Page rules and WAF rules can be set based on geolocation information. Administrators can create detailed rules based on users’ continent, country, province, city, and other geographic information. For example, a specific upstream proxy can be set for users from the United States, with a request rate limit of 10,000 per second.

  3. Optimized DNS Resolution: The system can determine the user’s geolocation and ISP based on their source IP, thereby returning the optimal DNS resolution results.

Database Selection

You can choose to obtain IP geolocation databases through the following methods:

  • Commercial IP geolocation databases purchased from MaxMind, ipip.net, or qqzeng
  • MaxMind’s free product GeoLite2
  • Custom IP geolocation database

Below, we will detail how to use the MaxMind Lite (i.e., free GeoLite2) database in OpenResty Edge.

Configuring MaxMind Lite Database

Step 1: Obtain MaxMind License Key

  1. Visit the MaxMind official website
  2. Register and log in to your account
  3. Generate a License Key in the control panel

MaxMind License Key Generation Interface

Step 2: Configure in OpenResty Edge Admin

  1. Log in to the OpenResty Edge Admin console
  2. Go to Global Settings

Global Settings Entry

  1. Click on IP Geolocation Database

IP Geolocation Database Settings

  1. Select Maxmind Lite

Select Maxmind Lite

  1. Enter the previously obtained MaxMind License Key
  2. Click the Save button

Note: The system will automatically verify the entered License Key. An appropriate error message will be displayed if it’s incorrect or expired.

Database Update Mechanism

  • OpenResty Edge Admin automatically synchronizes with the IP geolocation provider daily to get the latest database.
  • The updated database is automatically synced to all OpenResty Edge Node gateway servers without administrator intervention.
  • The bottom half of the page displays the update log of the IP geolocation database, allowing administrators to check the synchronization status.

Important Notes

  • Even if the License Key expires, it won’t affect the business logic of OpenResty Edge Node gateway servers.
  • An expired License Key will only result in the inability to synchronize the latest data. The OpenResty Edge Node gateway servers can still use existing data.

Custom IP Geolocation Database

OpenResty Edge supports custom IP geolocation databases, which can be used in parallel with standard databases like Maxmind Lite, providing more precise geographic information for specific needs.

The custom IP geolocation database uses CSV format with the following data structure:

network,continent_iso_code,country_iso_code,country_name_en,province_name_en,city_name_en,latitude,longitude,isp
34.64.0.0/24,AS,KR,South Korea,,,37.46910095214844,126.45099639892578,
34.64.1.0/24,AS,KR,South Korea,,,37.46910095214844,126.45099639892578,
34.64.2.0/24,AS,KR,South Korea,,,37.46910095214844,126.45099639892578,

IP Geolocation Query

The OpenResty Edge Admin console provides a convenient IP address query function:

You can use this function to:

  • Perform query tests after configuring the IP geolocation database to confirm the correct configuration.
  • Quickly verify when there are questions about the geolocation information of IP addresses reported by OpenResty Edge Node gateways.

By following these steps, you can easily configure and utilize the IP geolocation database, fully utilizing OpenResty Edge’s geolocation-related features.