This user guide will list out the steps to install the IP2Location HTTP Module in IIS server-wide.
Pre-requisite: .NET 3.5 framework MUST be installed before trying the steps below.
Download the module from https://ip2location.com/downloads/ip2location-http-module.zip
Download BIN database file at https://ip2location.com/download
Create a new folder and extract out all the files from both zip files into the new folder.
Create a Windows environment system variable to store the path of the new folder
To access the environment variables, open the Control Panel then double-click on System then click on Advanced System Settings. Click on the Environment Variables button to open up the Environment Variable settings. Under System variables, create a new variable called IP2LocationHTTPModuleConfig and set the value to the full path of the new folder.
Create a PowerShell script to install the IP2LocationHTTPModule.dll into the GAC
Create a PowerShell script called installgac.ps1 and paste the following code into it:
Set-location "C:\<folder>" [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacInstall("C:\<folder>\IP2LocationHTTPModule.dll") iisreset
Create a PowerShell script called uninstallgac.ps1 and paste the following code into it:
Set-location "C:\<folder>" [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacRemove("C:\<folder>\IP2LocationHTTPModule.dll") iisreset
In both scripts, edit the 2 lines containing the path to the full path for your new folder then save the scripts. Run installgac.ps1 to install the dll into the GAC. Keep the uninstallgac.ps1 for later.
Installing the module in IIS
Open the IIS Manager then navigate to the server level settings and double-click on the Modules icon. In the Modules settings, click on the Add Managed Module at the right-hand side. Key in IP2LocationHTTPModule for the Name and select IP2Location.HTTPModule as the Type. Click OK. Restart IIS to complete the installation.
Configure HTTP Module configuration in IP2Location-config.xml
<?xml version="1.0" encoding="utf-8"?> <IP2Location_Configuration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Settings> <BIN_File>C:\<folder>\<BIN filename></BIN_File> <Company_Name>Your Company Name</Company_Name> <License_Key>Your License Key</License_Key> <Custom_IP_Server_Variable></Custom_IP_Server_Variable> <Enabled_Server_Variables>True</Enabled_Server_Variables> </Settings> </IP2Location_Configuration>
What should I change?
- The full path for the BIN database file.
- * The company name that you have registered the license key
- * The license key for the IP2Location HTTP Module.
- If you are behind a proxy server, you may need to put HTTP_X_FORWARDED_FOR in this field.
- When the value is True, your webpages can have access to IP Geolocation data for your visitor’s IP address via server variables. You can turn this off by changing the value to False.
* The IP2Location HTTP Module will run in evaluation mode if you don’t key in your registration info.
Updating the module
To upgrade to a new version of IP2Location HTTP Module, you need to download and extract the new IP2LocationHTTPModule.dll file from the zipped file. Next, run the uninstallgac.ps1 from above to remove the existing dll from GAC then replace the existing dll in your folder with the latest one. Run installgac.ps1 to install the dll into the GAC.
Uninstalling the module
To uninstall the IP2Location HTTP Module, remove the module from the IIS Modules section in the IIS Manager. Next, run uninstallgac.ps1 to remove the dll from GAC and then just remove the IP2LocationHTTPModule.dll file from your folder.