views:

604

answers:

3

What is the preferred way of deploying a compojure/sinatra applications? I have multiple sites running on the host so i can't run jetty/mongrel on port 80. How should i handle multiple sites/applications running at the same host?

+4  A: 

Use a web server such as Apache that runs on port 80 and use virtual hosts to direct the traffic to the right app server. So basically you would run each application server (jetty/mongrel, etc.) on a different port and then in each virtual host would have a different configuration to use something like mod proxy to forward the traffic to the app server. You could use a different web server such as lighttpd or nginx. For the sinatra app you could also look at Phusion Passenger, a.k.a mod rails, a.k.a mod rack, which theoretically works with any rack app, although I've only used it with Rails.

If you look into it some more you'll find that there are various schemes for forwarding traffic to the app server from a web server, but the basic mechanism for doing this kind of thing always boils down to having a web server that listens on port 80 that uses name-based virtual hosts to then forward the traffic to the appropriate app.

pjb3
+3  A: 

I've been doing this kind of thing with various standalone servers (e.g., AllegroServe) for years. I've found the best approach to be:

  • Run each server on a different, non-privileged port (such as 8080)
  • Run pound (or Nginx etc.) on 80, configured to map requests to each application.

Pound is great, and the configurations end up very simple (unlike Nginx). It will also do SSL fronting and HTTP sanitization for you, which takes the burden off your application.

Rich
A: 

Use passenger! http://modrails.com - it is a plugin for apache and nginx that lets you (very) easily run a ruby app as a virtual host

Sean Clark Hess