This example shows how to quickly start using 51Degrees' on-premise IP intelligence in Nginx.
This example shows how to quickly start using 51Degrees' on-premise IP intelligence in Nginx. This example is available in full on GitHub.
This example uses the AsnName property which is available in the 51Degrees-IPIV4AsnIpiV41.ipi data file included in the ip-intelligence-data sub-module. When using a data file with a fuller set of properties, such as the Lite or Enterprise files, properties like RegisteredName, RegisteredCountry and RegisteredOwner can be requested in the same way.
When running on a local machine the client IP address reported by Nginx is a loopback or private network address, which has no useful IP intelligence associated with it. The second match below therefore reads a real IP address from the client_ip query string argument via the $arg_client_ip variable, overriding the reported client IP address for that match. This is the mechanism used by the tests. In production the variable argument can be omitted, as in the first match below, so the client IP address is used directly.
Before using the example, update the followings:
- Remove this 'how to' guide block.
- Update the %%DAEMON_MODE%% to 'on' or 'off'.
- Remove the %%TEST_GLOBALS%%.
- Update the %%MODULE_PATH%% with the actual path.
- Remove the %%TEST_GLOBALS_HTTP%%.
- Update the %%FILE_PATH_IPI%% with the actual file path.
- Replace the nginx.conf with this file or run Nginx with
-coption pointing to this file. - Create a static file
ipiin the Nginxdocument_root.
In a Linux environment, once Nginx has started, run the following command:
Expected output:
Values are returned in the form "value":weight where the weight indicates the confidence the engine has in the value.
NOTE: All the lines above, this line and the end of comment block line after this line should be removed before using this example.
