Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently my Ubuntu server runs RubyOnRails applications with Apache2 + Passenger.

Now I need to deploy a Sinatra (Plain Ruby app) which needs to run on Thin instead of Passenger.

I'm familiar with configuring Apache and would like to continue in that manner, with the VirtualHosts (in sites-available) etc..

How can I "route" a VirtualHost in Apache to a Thin server?

share|improve this question
up vote 5 down vote accepted

You'll be configuring Apache as a "reverse proxy" - that search term will point you to a wealth of information regarding the configuration, but here's an example that should get you most of the way to the deployment you're looking for.

If you'll be using a different hostname and different <VirtualHost>, then you can do something like this:

<VirtualHost *:80>
    # Any normal settings you use go here; access logs, ServerAdmin, etc

    # Replace the 9999 below with the port that thin is using, note that it can't
    # be the same as Apache's port.
    # This can also be a service running on adifferent computer if you
    # use another IP address instead of
    ProxyPass /
    ProxyPassReverse /

An alternative configuration that may be of use to you would be to just make it a subdirectory of an existing <VirualHost>; you'd add a <Location> block to your existing config:

<Location /sinatra/>
share|improve this answer
Works perfectly! You just missed the / after ProxyPassReverse (path) – Frexuz Dec 30 '11 at 19:57
Oops, sorry about that. Fixed. – Shane Madden Dec 30 '11 at 20:57

You could use Varnish to route app requests. I did this at my last job on our RoR/Varnish/NGINX stack.

Besides, Varnish caching is awesome!

share|improve this answer
Doesn't seem to be free? And I still like to use Apache :) – Frexuz Dec 29 '11 at 20:32
What's not free? Varnish is open-source (though you didn't mention that "free" was a requirement...), and you can configure Apache to do anything that NGINX can! (Except be lightweight, of course... ;-) ) – gWaldo Dec 29 '11 at 21:22

I was looking for exactly the same thing.

Here's a short, clear article on that walks through setup of an Apache virtual-host that uses load-balancing to distribute requests to 3 thin servers.

share|improve this answer
Welcome to Server Fault. Please add some details of what is particularly helpful in the linked to article, in case the link breaks in future. – dunxd Apr 4 '13 at 15:22
@dunxd I'm not sure how to respond to that. The bulk of the article consists of example commands and files, and expected output. It doesn't seem to lend itself to summarisation beyond what I've already mentioned. – crantok Apr 5 '13 at 9:44
Sounds neither short nor clear then. To be considered a good answer here it should, in the vast majority of cases, stand alone. Links are great, but can be broken all the time so in two days/weeks/years your answer may not be of any use if it just contains links. – dunxd Apr 5 '13 at 21:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.