2

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?

Frexuz
  • 123
  • 1
  • 7

2 Answers2

6

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>
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
0

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!

gWaldo
  • 11,887
  • 8
  • 41
  • 68
  • 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