# Umbrella Elixir app with multiple endpoints

**URL:** <https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649>\
**Category:** Phoenix\
**Created:** [September 28, 2021, 10:09am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649 "2021-09-28T10:09:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronrussell](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@aaronrussell](https://community.fly.io/u/aaronrussell)\
**Post date:** [September 28, 2021, 10:09am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/1 "2021-09-28T10:09:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [September 28, 2021, 6:12pm UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/2 "2021-09-28T18:12:18Z")

</div>

How many subdomains are you thinking here?

Running a proxy is your best bet on [Fly.io](http://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](https://github.com/tallarium/reverse_proxy_plug)

---

<div class="post-metadata">

**Author:** ![chrismccord](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/chrismccord/32/50976_2.png) [@chrismccord](https://community.fly.io/u/chrismccord)\
**Post date:** [September 28, 2021, 6:31pm UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/3 "2021-09-28T18:31:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aaronrussell](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@aaronrussell](https://community.fly.io/u/aaronrussell)\
**Post date:** [September 29, 2021, 10:16am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/4 "2021-09-29T10:16:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lorenzomar](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@lorenzomar](https://community.fly.io/u/lorenzomar)\
**Post date:** [November 9, 2023, 6:56am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/5 "2023-11-09T06:56:47Z")

</div>

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:

- [api.foo.com](http://api.foo.com) → ApiEndpoint on port 1234
- [backoffice.foo.com](http://backoffice.foo.com) → BackofficeEndpoint on port 5678

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

---

<div class="post-metadata">

**Author:** ![lud-wj](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/lud-wj/32/46731_2.png) [@lud-wj](https://community.fly.io/u/lud-wj)\
**Post date:** [September 8, 2026, 10:40am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/6 "2026-09-08T10:40:32Z")

</div>

Hello @lorenzomar did you find a solution for this?

---

<div class="post-metadata">

**Author:** ![halfer](https://avatars.discourse-cdn.com/v4/letter/h/df705f/32.png) [@halfer](https://community.fly.io/u/halfer)\
**Post date:** [September 10, 2026, 5:25pm UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/7 "2026-09-10T17:25:23Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![lud-wj](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/lud-wj/32/46731_2.png) [@lud-wj](https://community.fly.io/u/lud-wj)\
**Post date:** [October 21, 2026, 8:36am UTC](https://community.fly.io/t/umbrella-elixir-app-with-multiple-endpoints/2649/9 "2026-10-21T08:36:45Z")

</div>

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.
