Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:lisa-temp [2018/07/18 14:16]
Lisa Clarke created
litespeed_wiki:lisa-temp [2018/07/18 14:23] (current)
Lisa Clarke [Step 5. Check DB by Lookup Command]
Line 1: Line 1:
 ===== Enabling GeoLocation ===== ===== Enabling GeoLocation =====
  
-Geolocation enables developers to enhance the user experience. Content and advertising may be customized for a specific user's country, showing pages more relevant to the location of the user. Admins can further enhance a site's security by blocking a client based on country.  Displays can be customized for the user's environment. This wiki describes the new GeoLite2 database (with the ''​%%.mmdb%%''​ extension), downloadable from [[https://​dev.maxmind.com/​geoip/​geoip2/​geolite2/​|here]].  To use the legacy databases (''​%%.dat%%''​ extension) see the description for setting up legacy databases[[https://​openlitespeed.org/​mediawiki/​index.php/​Help:​GeoLocation_Setup|here]].+Geolocation enables developers to enhance the user experience. Content and advertising may be customized for a specific user's country, showing pages more relevant to the location of the user. Admins can further enhance a site's security by blocking a client based on country.  Displays can be customized for the user's environment. ​ 
 + 
 +This wiki describes the new GeoLite2 database (with the ''​%%.mmdb%%''​ extension), downloadable from [[https://​dev.maxmind.com/​geoip/​geoip2/​geolite2/​|here]].  To use the legacy databases (''​%%.dat%%''​ extension) see the description for setting up legacy databases[[https://​openlitespeed.org/​mediawiki/​index.php/​Help:​GeoLocation_Setup|here]].
  
 ==== Step 1. Install ==== ==== Step 1. Install ====
  
-The GeoLite2 databases are updated frequently and will regularly have to be downloaded. The description of automating this download by MaxMind is [[https://​dev.maxmind.com/​geoip/​geoipupdate/​|here]].  It is strongly recommended that while you may want to test by downloading the databases manually that you have them updated automatically. Full support for all of the databases (both the free ones and the subscription ones) are included.  You need to download the databases to a known location on your system.  The automatic update will load them into ''​%%/​usr/​local/​share/​GeoIP%%''​ and the instructions will assume that you are loading the two free ones: ''​%%GeoLite2-Country.mmdb%%''​ and ''​%%GeoLite2-City.mmdb%%''​ and can be followed to setup access to the paid databases as well..+The GeoLite2 databases are updated frequently and will regularly have to be downloaded. The description of automating this download by MaxMind is [[https://​dev.maxmind.com/​geoip/​geoipupdate/​|here]].  It is strongly recommended that while you may want to test by downloading the databases manually that you have them updated automatically. ​ 
 + 
 +Full support for all of the databases (both the free ones and the subscription ones) are included.  You need to download the databases to a known location on your system.  The automatic update will load them into ''​%%/​usr/​local/​share/​GeoIP%%''​ and the instructions will assume that you are loading the two free ones: ''​%%GeoLite2-Country.mmdb%%''​ and ''​%%GeoLite2-City.mmdb%%''​ and can be followed to setup access to the paid databases as well..
  
 ==== Step 2. Setup ==== ==== Step 2. Setup ====
Line 14: Line 18:
 /​usr/​local/​share/​GeoIP/​GeoLite2-Country.mmdb /​usr/​local/​share/​GeoIP/​GeoLite2-Country.mmdb
 </​code>​ </​code>​
-Set **DB Name** to: ''​%%COUNTRY_DB%%''​ {{https://​openlitespeed.org/​wp-content/​uploads/​2018/​07/​iptogeo_config-2.jpg?​805x397}} Similarly, add the city database by specifying **DB File Path:** ''​%%/​usr/​local/​share/​GeoIP/​GeoLite2-City.mmdb%%''​ and **DB Name:** to: ''​%%CITY_DB%%''​ Navigate to **Web Admin > Configurations > Your Virtual Hosts > Rewrite** to add rewrite rules that will control the redirect:+Set **DB Name** to: ''​%%COUNTRY_DB%%'' ​ 
 + 
 +{{https://​openlitespeed.org/​wp-content/​uploads/​2018/​07/​iptogeo_config-2.jpg?​805x397}} ​ 
 + 
 +Similarly, add the city database by specifying **DB File Path:** ''​%%/​usr/​local/​share/​GeoIP/​GeoLite2-City.mmdb%%''​ and **DB Name:** to: ''​%%CITY_DB%%'' ​ 
 + 
 +Navigate to **Web Admin > Configurations > Your Virtual Hosts > Rewrite** to add rewrite rules that will control the redirect:
  
 <​code>​ <​code>​
Line 22: Line 32:
 </​IfModule>​ </​IfModule>​
 </​code>​ </​code>​
 +
 Refer to [[http://​dev.maxmind.com/​geoip/​legacy/​mod_geoip2/#​Redirecting_a_client_based_on_country|Maxmind]] for more rewrite examples. Refer to [[http://​dev.maxmind.com/​geoip/​legacy/​mod_geoip2/#​Redirecting_a_client_based_on_country|Maxmind]] for more rewrite examples.
  
Line 30: Line 41:
 == Method 1: == == Method 1: ==
  
-From [[https://​hide.me/​en/​proxy|This site]], we can simply put in a web IP and choose a country from three(USA, Germany, Netherlands). If you want more than three countries, then you need to register for a paid plan. {{https://​openlitespeed.org/​wp-content/​uploads/​2018/​06/​Geo-3.png?​887x381}}+From [[https://​hide.me/​en/​proxy|This site]], we can simply put in a web IP and choose a country from three(USA, Germany, Netherlands). If you want more than three countries, then you need to register for a paid plan.  
 + 
 +{{https://​openlitespeed.org/​wp-content/​uploads/​2018/​06/​Geo-3.png?​887x381}}
  
 == Method 2: == == Method 2: ==
  
-You can choose a free proxy server from online free resources, e.g. [[https://​free-proxy-list.net/​|Free_Proxy]] {{https://​openlitespeed.org/​wp-content/​uploads/​2018/​06/​Geo-1.png?​1011x484}} Setup the proxy IP with your browser. Here are the steps for Chrome:+You can choose a free proxy server from online free resources, e.g. [[https://​free-proxy-list.net/​|Free_Proxy]] ​ 
 +{{https://​openlitespeed.org/​wp-content/​uploads/​2018/​06/​Geo-1.png?​1011x484}} 
 + 
 +Setup the proxy IP with your browser. Here are the steps for Chrome:
  
   - Click on **Settings**.   - Click on **Settings**.
Line 50: Line 66:
 ==== Step 4. Check Correct IP is Set ==== ==== Step 4. Check Correct IP is Set ====
  
-You can check source IP via LiteSpeed default php page ''​%%http://​yourdomain/​index.php?​act=phpinfo%%''​.  Check the ''​%%$_SERVER%%''​ variables, and look for the ones which begin with ''​%%GEOIP_%%''​. {{https://​openlitespeed.org/​wp-content/​uploads/​2018/​07/​geoenv.jpg?​533x235}} The environment variables are based on the default environment definitions.  The advanced section below shows you how to customize them for your environment to allow you to specify environment names, display language, additional databases, etc.+You can check source IP via LiteSpeed default php page ''​%%http://​yourdomain/​index.php?​act=phpinfo%%''​.  Check the ''​%%$_SERVER%%''​ variables, and look for the ones which begin with ''​%%GEOIP_%%''​. ​ 
 + 
 +{{https://​openlitespeed.org/​wp-content/​uploads/​2018/​07/​geoenv.jpg?​533x235}} 
 + 
 +The environment variables are based on the default environment definitions.  The advanced section below shows you how to customize them for your environment to allow you to specify environment names, display language, additional databases, etc.
  
 ==== Step 5. Check DB by Lookup Command ==== ==== Step 5. Check DB by Lookup Command ====
  
-A very useful MaxMind tool is downloaded and compiled with the source code release: ''​%%mmdblookup%%''​.  Use this tool to view an entry in the database for a specific IP. For example, to see the country name definition for the IP address 47.22.54.182 enter from a command prompt in the openlitespeed directory: ''​%%libmaxminddb/​bin/​mmdblookup --file /​usr/​local/​share/​GeoIP/​GeoLite2-Country.mmdb --ip 47.22.54.182 -v%%''​ The output is very detailed and can be informative as it shows you the information available in the database:+A very useful MaxMind tool is downloaded and compiled with the source code release: ''​%%mmdblookup%%''​.  Use this tool to view an entry in the database for a specific IP. For example, to see the country name definition for the IP address 47.22.54.182 enter from a command prompt in the openlitespeed directory: ​ 
 + 
 +''​%%libmaxminddb/​bin/​mmdblookup --file /​usr/​local/​share/​GeoIP/​GeoLite2-Country.mmdb --ip 47.22.54.182 -v%%'' ​ 
 + 
 +The output is very detailed and can be informative as it shows you the information available in the database:
  
 <​code>​ <​code>​
  • Admin
  • Last modified: 2018/07/18 14:16
  • by Lisa Clarke