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?

1 Like

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

1 Like

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.

2 Likes

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?