Umbrella Elixir app with multiple endpoints

I’m building an Elixir app with an umbrella architecture which we plan to put on Fly. It has several endpoints which currently run on different ports and we plan to point different subdomains at different endpoints.

Is there a “Fly way” of routing different subdomains to the correct port? Or will it be necessary to run an nginx app in front of everything and do the top-level routing from that?

How many subdomains are you thinking here?

Running a proxy is your best bet on Fly.io right now. But what I’d do is add an Elixir app with an endpoint that handles proxying for you, expose that as the public service, and run the other apps privately.

We’ve been using this plug to do something similar: GitHub - tallarium/reverse_proxy_plug: 🔛 an Elixir reverse proxy Plug with HTTP/2, chunked transfer and path proxying support

If you are planning on running the child applications all in the same VM, you could also create a new child application that starts a bare-bones endpoint which does the routing to the appropriate endpoint. The big caveat with this approach is the endpoint socket declarations are intercepted in a special case which won’t work if forwarding from another plug upstream, so to support this approach you’d need to specify the socket declarations of all the other children in the child proxy app. If that is a non-starter then a proxy app in another VM which does the reverse proxy, or Nginx is the way to go as Kurt mentioned.

Using a barebones proxy endpoint in the same umbrella is something we’ve considered. Can I just clarify the caveat you explained?

If I understand this correctly, if we use phoenix channels or liveview in any of our endpoints, they must be declared in the proxy endpoint. Is that correct?

Apologies for reviving an old thread, but I believe it maintains the context. Please advise if starting a new one would be preferable.

How can I configure a proxy to redirect requests to specific ports based on the subdomain?
For example:

Is there a way to do this on Fly?
Thanks in advance for your support

Hello @lorenzomar did you find a solution for this?

@lud-wj It’s possible there are some Fly network tricks for this. However a Docker-friendly way that would almost certainly work (at least based on lorenzomar’s requirements) is a Traefik instance. It’s a very flexible proxy system that can forward traffic based on pretty much any rules you like. I’ve not used it for ten years, but it was good then, and I expect it is still maintained.

The nice thing about doing this in Docker and not Fly config is that your local instance (run with Docker Compose) will run the same way.

Hi @halfer sorry for the late reply.

Yes this could be a nice solution but it puts some security responsibilities on my side and I don’t feel confident with that.