PierreRambaud/gemirro

Hosting from a subroute

Closed this issue · 3 comments

I'd like to host genmirro from a subroute.
Example: http://example.com/genmirro would proxy_pass to http://localhost:2000

Modifying the nginx config on the homepage, this might look like this:

upstream gemirro {
  server localhost:2000;
}

server {
  server_name rbgems;

  location ^~ /genmirro {
    rewrite ^/gemirro(/.*)$ $1 break;
    proxy_pass http://gemirro/;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

This configuration works as a mirror, but the web routes do not account for the additional path when calculating /. So, for example, I get uris that point to http://example.com/gem/rack instead of the correct http://example.com/genmirro/gem/rack

Is there configuration to pass a header to the proxy or set an alternative root route so that a configuration like this would work?

Hi, look like it's a nginx configuration problem. Just try to play with proxy_pass.

proxy_pass http://gemirro/gemirro

Otherwise, I will try to have a look as soon as possible

I don't think it's nginx proxy configuration. The site is being served, it's just the views that have the wrong urls. Even if I include a subroute in the proxy_pass directive, the underlying server has to honor that setting.

I saw gemirro is backed by Sinatra, so I think if I shuffle some config around I could run Gemirro::Server directly with passenger and use passenger to set the subroute in a way that Sinatra will recognize it.

Actually, that worked surprisingly well. Whatever variables passenger sets for Sinatra/Rack makes almost everything work.

The only thing that doesn't serve correctly are the static assets in the layout files, which would just need something like https://github.com/wbzyl/sinatra-static-assets/ to respect the sub-URI