Running Drupal behind a reverse proxy

I was supposed to move one of the Drupal sites I’m maintaining behind a Reverse Proxy. The migration was smooth as it could get, but soon throttiling was an issue. All requests were coming from the Proxy server, and Drupal didn’t seem to automagically detect the client IP based on the X-Forwarded-For header.

So I set about investigating what can be done. As I discovered, automagic client IP detection is only available in Drupal 6 (At the time of writing, under development). I went about porting the changes to Drupal 5.x. Porting was as easy as it can be, but it was not working.

Further investigation lead to one of the site configurations; I had enabled Normal Caching in the Drupal site. It was not acceptable to switch off caching, so I went about debugging this code to make it work with caching enabled. Finally I was able to fix the issue, it was trivial but it was not easy to debug. The fix involved removing cached IP address for every request such that the correct IP will be detected. See my patch in drupal.org at http://drupal.org/node/219825.

Hope this helps someone.

The Google Highly Open Participation Contest

Following on from the success of the Google Summer of Code program, Google is pleased to announce a new effort to get young people involved in open source development. Google has teamed up with the open source projects such as Apache Software Foundation, Drupal, GNOME, Joomla!, MoinMoin, Mono, Moodle, Plone, Python, and SilverStripe to give student contestants the opportunity to learn more about and contribute to all aspects of open source software development, from writing code and documentation to preparing training materials and conducting user experience research.

If you’re a student age 13 or older who has not yet begun university studies, you could help out these projects. In return, you’ll learn more about all aspects of developing software – not just programming – and you’ll be eligible to win cash prizes and the all important t-shirt! You will, of course, need your parent or guardian’s permission to participate where applicable.

To Read more and take part go to http://code.google.com/opensource/ghop/2007-8/.

If you have already begun university studies like me you could always spread the word 🙂

Flying light with lighty

I moved all my sites to my all new server. There I’m running Lighttpd as the front facing web server. I do have Apache HTTP Server running for the sake of svn serving. It was not very hard to migrate sites from Apache HTTP Server to Lighttpd. Only feature I missed was .htaccess file support or substitute. I just had to migrate all the operations taking place in the .htaccess files to the Lighty configuration file.

Overall migration was smooth. I have nothing to complain, memory foot print is small as it could get. Since I’m serving only PHP and Python I’m making use of FastCGI and it is really fast. You wouldn’t believe me if I tell you the performance gains. I can serve 700 requests per second when it comes to my Geo-IP web service (I believe the limit was the resources on the test machine), the server is not even sweating. If I was running the same application on Apache HTTP Server it would barely serve 230 requests per second, 204% performance gain.

If you visit any of my sites except for the blog itself (which is hosted at Blogger.com) you would see the performance. mohanjith.net responds within a second, that’s lighting fast. All this with a Debian running on Xen with 128MB physical memory and 256MB swap.

I would recommend Lighty to any one with simple serving requirements. It saves lot of server resources.