Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

up vote 3 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>
    ServerName sinatra.example.com
    # 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 127.0.0.1
    ProxyPass / http://127.0.0.1:9999/
    ProxyPassReverse / http://127.0.0.1:9999/
</VirtualHost>

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/>
    ProxyPass http://127.0.0.1:9999/
    ProxyPassReverse http://127.0.0.1:9999/
</Location>
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 rackspace.com that walks through setup of an Apache virtual-host that uses load-balancing to distribute requests to 3 thin servers.

share|improve this answer
1  
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

 
discard

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.