Hey Itamar,

Using DNS to redirect to a port will only be possible if you're using SRV
records (I'm not sure what mesos-dns uses) but this doesn't really matter
as it won't be looked up by the browser.

For this solution I have a small daemon written in go running on a number
of hosts (that aren't slaves), this locates the marathon master, and pulls
down my apps - I tag apps with a "Host" label (something like
foo.example.com) and then I create a haproxy config file with backends
directed by the host header. There's a few more smarts in it around only
pulling apps with a green healthcheck etc.

This daemon manages the lifecycle of haproxy on the node - it uses a
polling model, not an event driven one from the marathon event stream.

Another solution that uses the event-stream is this one
https://github.com/QubitProducts/bamboo - it's been a while since I checked
it out, but was functional back then.

Hope that helps.

ryan

On 2 August 2015 at 07:10, Itamar Ostricher <[email protected]> wrote:

> I use marathon to launch a nginx-docker-container named "my-app", and set
> up Mesos-DNS, such that "my-app.marathon.mesos" returns the IP of the slave
> running the container (e.g. 10.20.30.40).
>
> Now, "my-app" is running on some dynamically-allocated port (e.g. 31001),
> but I would like http://my-app.marathon.mesos/foo to hit my app at
> http://10.20.30.40:31001/foo
>
> Is there a "best practice" way to achieve this behavior?
>
> I was thinking about a proxy running on each slave, listening on port 80,
> redirecting incoming HTTP requests based on the request host to the correct
> port on localhost. The "correct port" can be determined by querying
> mesos-dns itself.
>
> This sounds like a pretty common use-case, so I wondered if anyone can
> point me at an existing solution for this.
>
> Thanks!
> - Itamar.
>

Reply via email to