Thursday, March 01, 2012


How to redirect your website base on country ip request, Apache, geoip, rewrite

Install the mod-geoip

sudo apt-get install libapache2-mod-geoip

Enable the mods:

sudo a2enmod rewrite
sudo a2enmod geoip

In your file ".htaccess" add these lines:

# if country is PT
RewriteEngine on
RewriteRule ^(.*)$

# else
RewriteEngine on
RewriteRule ^(.*)$

You have to configure the virtual host to read the .htaccess file.
<directory /var/www/site/>
 Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

In your file "httpd.conf" add these lines:

GeoIPEnable On
GeoIPDBFile /usr/local/share/geoip/geoip.dat

Download the file from and put it in /usr/local/share/geoip/geoip.dat

There are a lot of versions. This one is free for countries :)

Using mod_spdy With Apache2 On Ubuntu 12.04

SPDY runs over HTTPS, so we need an HTTPS-enabled web site to test SPDY. Please note that SPDY will fall back to HTTPS if the user's browser does not support SPDY or if things go wrong, so installing mod_spdy doesn't hurt your existing setup.

a2enmod ssl
a2ensite default-ssl
/etc/init.d/apache2 restart

cd /tmp
dpkg -i mod-spdy-*.deb
apt-get -f install
/etc/init.d/apache2 restart
Post a Comment

How to get the IP address of the docker host from inside a docker container

/sbin/ip route|awk '/default/ { print $3 }'