How to set up more than one reverse proxy with Apache/Web Service on OS X Server

I’ve been using a reverse proxy on OS X Server’s web service (aka. Apache) for a while so that my Ruby on Rails application appears in the same domain as our main website. The reverse proxy was translating all requests to a specific URL to redirect to a Mongrel cluster. This was very easy to set up (with a little help from the official Web Technologies Administration guide). However, we’ve recently started to expand the amount of testing that we do and so we decided to set up separate production and user acceptance testing (UAT) installations, which should also be accessed from the single parent domain. That should have been a straight forward task in Server Admin, however I quickly realised that it allows you to specify only a single reverse proxy (even though Apache has no such restriction).

It turns out that the only way to do this is to step outside of Server Admin and change the Apache config manually (which is a shame). However it’s not very difficult.


In the terminal, navigate to


Here you should see a .conf file that corresponds to each of your sites in Server Admin, open whichever one you’re interested in using sudo, eg. sudo open 000_any_80_mysite.conf (It’s always a good idea to back up any important files like this before editing them) This file contains all of the config for that particular site, however the part that we’re interested in is inside the <IfModule mod_proxy_balancer.c> tag.

I’m assuming that have already set up one reverse proxy in Server Admin (which you can then use to copy-and-paste to create more), and so you should see something like this:

<IfModule mod_proxy_balancer.c>
	ProxyPass /subsite/ balancer://balancer-group/
	ProxyPassReverse /subsite/ balancer://balancer-group/
	<Proxy "balancer://balancer-group">
		BalancerMember http://hostA:3000/subsite loadfactor=34
		BalancerMember http://hostB:3000/subsite loadfactor=33
		BalancerMember http://hostC:3000/subsite loadfactor=33

Obviously these are made up details, but it indicates a cluster of three (Mongrel Rails) servers that are proxied at /subsite on this site.

To create more reverse proxies, copy and paste the whole contents of the <IfModule> tags once for each additional reverse proxy (ie. you’ll need a ProxyPass command and a ProxyPassRevere command, as well as <Proxy> tag), then update the details of the newly created proxies with the new subsite url and BalancerMember details. You’ll also need to change the balancer://balancer-group/ url (in both the ProxyPass and ProxyPassReverse commands and the <Proxy> tag) to a unique url with the balancer::// “protocol” to uniquely identify your new load balancer group (this url is internal to Apache and so you can call it whatever makes sense so long as it doesn’t clash with any other load balancer group).

Now you should have two similarly defined reverse proxies. Restart Apache (I find the easiest way is to stop and start the web service in Server Admin) and the new reverse proxy url should redirect you to the correct place. You won’t be able to see your new reverse proxy in Server Admin, however if you keep the name of the original load balancer group as “balancer-group” then at least you will still be able to see that one.


The problem with this method is that you can no longer edit this site in Server Admin – doing so will overwrite your changes with whatever is visible in Server Admin, and since Server Admin can only display one reverse proxy it will delete any additional reverse proxies that you have defined.


About this entry