Re: using nginx rewrite rules with sinatra

Martin DeMello <[email protected]> Wed, 25 Sep 2019 00:45:47 -0700
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAFrFfuEyGAshv2Sj8tFgo99sUEiGagTOEt86x4cCaQ2+tdJggg@mail.gmail.com>
On Tue, Sep 24, 2019 at 9:21 PM Ryan Davis <[email protected]> wrote:

> > On Sep 24, 2019, at 13:47, Martin DeMello <[email protected]>
> wrote:
> >
> > 2. Expose it at host:port (currently with puma, though I'm happy to
> change that if some other server makes it easier), and put it behind nginx
> with a prefix, e.g. myapp, so that the actual urls are /myapp/input and
> /myapp/process which rewrite to host:port/input and host:port/process
>
> POST often responds with a redirect. Let's say /myapp/new -> /myapp/form
> -> /myapp/list. Who should make sure that /myapp is on the redirect if the
> redirect is coming from your sinatra app? It sounds like maybe a raw rack
> layer underneath your app to just deal with adding/removing this prefix
> might be the right approach, but I'm not sure it's the best idea.
>
> What's your motivation for keeping the sinatra side ignorant of the prefix?
>

It just seems conceptually cleaner - the prefix isn't a detail of my app,
it's a detail of the way I'm hosting this particular instance of it (e.g.
if I put the app up on github, someone else might want to host it with an
entirely different prefix, or no prefix). Perhaps my best option is to have
sinatra be aware of the prefix but set it in a single place and use a
variable everywhere in the app.

martin


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>