Entrepreneurship, Linux, and Ruby
Posts tagged phusion passenger
Deploying Sinatra to a sub-URI using Passenger
Apr 8th
It's not hard, but it turns out there's a trick to it. I've run into this problem twice now, so I figure it should be documented. This is the solution if your "/" route is resulting in "Not Found" or an Apache directory listing.
You can read more about the problem at Ardekantur's "Phusion, Rack, Sinatra, and sub-domains", but here's my quick solution:
- Disable mod_autoindex if it is enabled.
- Make sure your RackBaseURI does not have a trailing slash.
- Add this before_filter to your Sinatra app:
before do request.env['PATH_INFO'] = '/' if request.env['PATH_INFO'].empty? end
I suppose an alternative solution would be feasible using Rack middleware, but this is what I'm using. Thanks to Ryan Funduk for helping me figure this stuff out.

