dsw88
dsw88

Reputation: 4592

Host Sinatra app off a non-root path using Rack

I'm setting up a Geminabox repository, which is a Rack app (Sinatra based). I'm running the app on the Passenger standalone server.

Currently the app is being hosted off the root path, so it's available at :3000/

I need to host it off a non-root path, something like :3000/rubygems. I've not got a lot of experience with Rack apps or Passenger, so I'm not sure where I can accomplish this.

So, on an app stack composed of Passenger, Rack, and Sinatra, where could I easily configure this app to be hosted off of a non-root path like :3000/rubygems?

Upvotes: 2

Views: 413

Answers (1)

dsw88
dsw88

Reputation: 4592

It turns out you can use the map function in your config.ru files for Rack apps. This will host the application off that path.

Here's an example:

map "/my-sub-path" do
  run MyModule::MySinatraApp
end

That will run that app off /my-sub-path, and all requests to that path will be rewritten to the root (/) path when they reach your Sinatra (or other) app.

Upvotes: 2

Related Questions