Amazon ELB & IPs in apache logs & rewrites
If you’re using an Amazon ELB (Elastic Load Balancer) you’ll notice in your apache logs that Amazon passes over the IP of the ELB and not the client making the connection. So your logs will contain connections from 10.10.x.x or something similar. You can’t make any changes on the ELB to overcome this but you can obtain the IP from within the HTTP Header using X-Forwarded-For
Capturing the IP in your Apache logs.
By default your Apache log format in /etc/httpd/conf/httpd.conf will look like
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/acces_log combined
Change this to
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded
You will now have the IP inside your apache logs.
Doing re-writes on X-Forwarded-For IP’s
It is possible to run rewrites based on the X-Forwarded-For HTTP header, I’m not sure if this is a feature relating to a specific version of Apache but certainly works in 2.2.. Simply use the following RewriteCondition
RewriteCond %{HTTP:X-FORWARDED-FOR} ^xxx.xxx.xxx.xxx$
There you go, hope it helps.
Read MoreSupporting a pop star
A good friend of mine, Jamie whom I met on holiday a few years ago has always had a dream to become a pop star. The thing is, a lot of people have said that they would like to become one but never had the backing or the drive/ambition let alone the talent to do so.
Jamie, is different.. Anyway, I’m pleased to admit that I support Jamie by providing technical support to him and hosting his website www.jamie-stimpson.co.uk His latest single entered the UK R & B Chart and went on to be a big hit… I do this, because I not only believe in him, but he’s also a very good friend.
As a favour to me, would you mind checking out his website and listening to his tracks. Thank you.
Read MoreFixing the crap WIFI on the Virgin Media SuperHub
So, you’ve taken stock of your new Virgin Media SuperHub (UK Broadband) and you might have realised the WIFI is shocking. The stability of the WIFI connection is something that Virgin and Netgear (the makers of the SuperHub) really need to address. Several updates have been released for the box but none have fixed the issue so far… Read on for a couple of fixes
Read MoreBASH Aliases; Linux command line shortcuts
You may already know this or you may have forgotten but you can setup aliases or shortcuts for Linux command line. So if there is a command your always using, such as
cd /var/log/httpd
then your best off creating an alias for this..
Read MoreFollowing log files with tail -f
UNIX is a majestic onion of discovery. Every day a new layer of understanding can be peeled away to give some new pungent goodness. Today’s was the ‘follow’
option of the tail command.
Read More
Checking all MySQL tables
It’s well known that MyISAM tables are prone to corruption and need to be regularly checked and repaired. Moreover, in a production environment, it can be beneficial to run a daily check of all tables and mail news of any errors to an appropriate developer/DBA.
Read More
Rsync a directory excluding pesky .svn dirs
rsync has “-C, –cvs-exclude” option could exclude the following items: RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/ .git/ .bzr/
Then you can just use following command:
rsync -aC --exclude=.repo/ srcDir/ desDir/
Read More
