[erlang-questions] Deploying multiple webapps
Wed Dec 16 21:31:02 CET 2015
On Wed, Dec 16, 2015 at 01:21:09AM +0100, Loïc Hoguin wrote:
> I have been working on RabbitMQ these past few months, and one of
> the tasks I got assigned was to switch the Web components from
> Webmachine to Cowboy.
> RabbitMQ already had a way to have different services on different
> URLs running under the same port, as you describe. So my work was in
> part to make it work with Cowboy.
> I didn't have to change much.
> I made a tiny middleware that queries the RabbitMQ component keeping
> tracks of all the services, that then returns with the 'dispatch'
> environment variable added. This middleware runs just before the
> cowboy_router middleware: https://github.com/rabbitmq/rabbitmq-web-dispatch/blob/rabbitmq-management-63/src/rabbit_cowboy_middleware.erl#L27
> The process keeping tracks of all services simply has a mapping from
> /service1/ to the service's dispatch list (/service1/ is added
> This works pretty well, is all on one node, one port, just like you
> need, and doesn't require much code. I suppose it wouldn't be too
> difficult to extract and make it its own project, if that's
> something people need.
> Note that everything I talk about here has not been merged yet; but
> I'm getting close to completion (all tests pass, yada yada).
It sounds like it would be a big part of a solution of what I'd
like to do.
I guess another analogy of what I'm trying to do is that it's very
like a Java Servlet container: something that I can drop services
into, where the container handles the main HTTP serving and holds the
configuration of which services it runs, where I don't have to
recompile, rebuild or redeploy the container to alter the set of
services running in it.
> On 12/16/2015 12:41 AM, Hugo Mills wrote:
> > I've got a collection of small services, with minimal coupling
> >between the back ends of those services (orchestration is done mostly
> >client-side). I'd like to put an HTTPS interface in front of each one
> >-- say, with cowboy.
> > What I'd also like to be able to do, at least in principle, is
> >deploy some arbitrary subset of those services on each machine in my
> >(comedically-named) server farm. I'd like to be able to do this with
> >one TLS configuration, and preferably under a single port.
> >i.e., access my services through
> > Now, in python-land, which is largely where I come from, I'd set up
> >Apache with mod-wsgi, and deploy each WSGI app to a specific URL
> >within the same URL namespace. I'm not quite sure how to do that
> >easily with erlang+cowboy, because there seems to be no easy way of
> >treating a webapp as a unit within a larger server configuration. I
> >keep coming to one of two approaches:
> >1) Write each service completely independently (as HTTP), run it on a
> > distinct port, and splice together the URL namespaces through a
> > reverse proxy on a "normal" web server like Apache.
> >2) Find some way to automatically write a top-level router for cowboy,
> > for each set of services that I want to deploy to a machine.
> > I don't much like option 1, but I like option 2 even less. I guess
> >I could write some kind of "top-level" app that, given a bunch of
> >webapp modules (via a configuration file of some kind), gets a router
> >for each module and transforms those routers into a single router
> >config. Does such a thing already exist?
> > It all just feels a bit awkward, and I feel like I'm missing
> >something. What do other people do to put together this kind of setup?
> > Hugo.
> >erlang-questions mailing list
Hugo Mills | You've read the project plan. Forget that. We're
hugo@REDACTED carfax.org.uk | going to Do Stuff and Have Fun doing it.
PGP: E2AB1DE4 | Jeremy Frey
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: Digital signature
More information about the erlang-questions