Passing IPs to apache with nginx proxy

When you use nginx to proxy to apache , apache picks up the IP address of your nginx proxy as the client. A consequence of this is that apache log files, and any application running on the apache backend, will all receive the same IP address (for example 127.0.0.1 if apache and nginx are running the same server). Luckily, nginx provides a HTTP X-Forwarded-For header containing the clients real IP address, although apache doesn’t pick it up by default. To allow apache to recognize the original client IP, we need to install the mod_rpaf module. On ubuntu, this is as simple as installing a package : ...

August 10, 2009 · 2 min · Dave Perrett

InnoDB as default MySQL table type

To change the default MySQL table type, edit your my.cnf file (usually /etc/mysql/my.cnf on ubuntu), and add the following line to the [mysqld] section : default-table-type=innodb The resulting config will look something like this : ...

August 9, 2009 · 1 min · Dave Perrett

Flushing the DNS cache on OS X

I often find that OS X refuses to obey my /etc/hosts file for some time after I change it. It seems that often you have to manually flush the DNS cache by hand to force host file changes to take effect. Under pre-leopard systems, use lookupd : > sudo lookupd -flushcache Starting with Leopard, lookupd has been replaced with dscacheutil : > sudo dscacheutil -flushcache

August 5, 2009 · 1 min · Dave Perrett

MySQL table 'is marked as crashed'

I recently had a problem trying to use mysqldump where it was complaining that mysqldump: Got error: 145: Table './recurser/wp_options' is marked as crashed and should be repaired when using LOCK TABLES This corrupted wp_options table actually caused wordpress to think it was a fresh install, and showed the interface to create the admin user to anyone who accessed recurser which is a little scary :) The solution was to go to the actual database directory, and run myisamchk -r on the offending table : ...

June 18, 2009 · 1 min · Dave Perrett

HTTPSHandler error using python 2.5 and GAE on OS X

If you are getting an error complaining that ‘module’ object has no attribute ‘HTTPSHandler’ running python 2.5 on OS X : ...

June 6, 2009 · 1 min · Dave Perrett

Python 2.5 "ImportError: No module named _md5" on OS X

If you are getting an error complaining about missing md5 running python 2.5 on OS X : Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/dave/Desktop/setuptools-0.6c9-py2.5.egg/setuptools/command/easy_install.py", line 21, in <module> File "/Users/dave/Desktop/setuptools-0.6c9-py2.5.egg/setuptools/package_index.py", line 2, in <module> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 91, in <module> import hashlib File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/hashlib.py", line 133, in <module> md5 = __get_builtin_constructor('md5') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor import _md5 ImportError: No module named _md5 … you need to install py25-hashlib :...

June 6, 2009 · 1 min · Dave Perrett

python 2.5 zipimport.ZipImportError on OS X

If you are getting an error similar to the following trying to run pythin2.5 on OS X : zipimport.ZipImportError: can't decompress data; zlib not available … you need to install py25-zlib : > sudo port install py25-zlib

June 6, 2009 · 1 min · Dave Perrett

Exclude tables from mysqldump

Recently I was in a position where i wanted to exclude 2 large tables from mysqldump, without specifying every single table I wanted to back up. After a bit of searching, it seems you can easily exclude tables from mysqldump using the –ignore-table option : > mysqldump -u dave -ppassword -h localhost --ignore-table=my_db_name.my_table_name my_db_name …obviously substituting your own username, password, db name and table name etc . As far as i can tell you can use this option multiple times to exclude multiple tables

June 2, 2009 · 1 min · Dave Perrett

'spec/rake/spectask' errors doing rake db:migrate

If you get an error similar to the following while running rake db:migrate : error no such file to load -- spec/rake/spectask … you need to install the rspec gem : > sudo gem install rspec

April 29, 2009 · 1 min · Dave Perrett

Rename authors in a git repository

I recently imported the old Clutch code into git , but for some reason it ignored the authors.txt file I provided, and used the original svn user names. This info is based largely on this stack overflow post . First, clone your repository locally : ...

April 29, 2009 · 2 min · Dave Perrett