Installing mod_proxy on a Mac OS X - Tiger 10.4.8 1

Posted by Tim Connor Tue, 13 Mar 2007 08:13:00 GMT

I’m using Locomotive for my easy Rails install/set-up on my new iMac and been relatively unbothered by not having to download, build, configure, and manage a herd of tools. I installed MySQL, rather than be restricted to the included SQLLite3, but that is simple with the nice installers available from the MySQL AB. Now, I’ve come across the first more complicated “upgrade.”

With the default Locomotive (mongrel) set-up you end up with paths like localhost:3000. This is fine when you only ever have one site running, but causes a problem wih conflicted sessions when you have one site at :3000 and another at :3001. Now many of you are probably familiar with the idea of using Apache as a virtual hosting front-end/proxy. If you do so, and edit your hosts file (or take a quick trip to the NetInfo Manager in OS X) to map http://your_app to you have a much improved situation.

Unfortunately, most of the instructions involved in setting this configuration up, either explicitely presume an Apache 2 install, or walk you through installing it, and OS X comes with 1.3. In the middle of developing a couple apps you may not wish to take time off to fully configure and mess with a full web server upgrade. It’d be much nicer to just add mod_proxy (the one missing piece), configure your vhosts, and call it good.

Figure out your apache version

shell$ httpd -v
Server version: Apache/1.3.33 (Darwin)
Server built: Aug 19 2006 07:55:18

Grab it from the archive and unzip

shell$ curl -O
shell$ gnutar -xzf apache_1.3.33.tar.gz

Use apxs to build and install mod_proxy

sudo apxs -c -i src/modules/proxy/mod_proxy.c

Configure and you’re off (remember to uncomment the LoadModule and AddLoader)

<VirtualHost *:80>
ServerName your_app
ErrorLog /dev/null
CustomLog /dev/null common
ProxyPass /
ProxyPassReverse /