Mobile app version of vmapp.org
Login or Join
Pierce454

: Is there a way to know if apache receives a request from a public IP not local to your country? I'm looking for ways to know if an apache server receives a request , from another country

@Pierce454

Posted in: #Apache #ApacheLogFiles #Geolocation #Geotargeting #Logging

I'm looking for ways to know if an apache server receives a request , from another country (e.g germany) considering its a fair request (no spam , or proxies). I want it either to appear this as a separate entry(using dns request) in apache logs? or some kind of alert . Can this be possible.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce454

1 Comments

Sorted by latest first Latest Oldest Best

 

@Speyer207

You can have Apache2 detect where the user is coming from and adjust the variables in the header so yes you can log it, and setup a cron job to phrase the logs but you need access to a GEO IP database. Not all domains, hosts resolve as .de and even if its .de doesn't mean they are German based.

mod_geoip2 Apache module

This little module allows you to detect visitors using a GEOIP database and then redirect, block, log, and many other variables within the htaccess or header request.

For example

GeoIPEnable On GeoIPDBFile /path/to/GeoIP.dat

# Redirect one country RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$ RewriteRule ^(.*)$ www.domainname.com [R,L]

# Redirect multiple countries to a single page RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$ RewriteRule ^(.*)$ www.domainname.net/DE [R,L]


The eaiest solution would to redirect them to a DE part of the site making the phrasing easier. You just duplicate the page and use noindex so that doesn't effect your rankings.

Check out mod_geoip2

GEO IP Databases Cost Money

IP addresses are ever expanding and changing from one country to another, in order to keep your database up to date you need to pay for this per X amount of requests. I recommend Maxmind for using their API as allows lot of freedom and pricing isn't to bad.

Simple Solution

Sorry there is no simple solution to do this, you could by all means resolve the host but many ISP's in Germany don't use just .de they use .net .com and so on! so your need a database to know what is what.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme