I’ve deployed an Elixir umbrella project with three Phoenix sub-apps, each listening on their own port (8080, 8081, 8082) How do I configure the fly.toml file to listen to the separate ports? Fly.io only seems to handle interaction over port 80.
fly.toml may use port 80, but you can change it.
Where to change it depends on whether it’s an internal port, or exposed to the outside world.
Hopefully their linked doc shows how/where. For example you can put multiple
[[services.ports]] in there to expose a web app to the outside world on e.g 80 and 443:
Thanks for your reply. Yeah I’ve seen this doc and tried a dozen permutations. My docker command is
docker run -p 8080:8080 -p 8081:8081 -p 8082:8082 andyldk/phoenix_live_editable. Can anyone point me to a full
fly.toml file that successfully runs a multi-port app on Fly.io? Near as I can tell, Fly.io will route port 80 to another internal port (like 8082), but will not let me address calls to a specific port (like
If you want to expose multiple internal ports using different public ports then you’ll need to have multiple
[[services]] sections, for example:
[[services]] internal_port = 8080 protocol = 'tcp' [[services.ports]] handlers = ['http'] port = 8080 .... [[services]] internal_port = 8081 protocol = 'tcp' [[services.ports]] handlers = ['http'] port = 8081
@charsleysa thanks for your inputs!
Well I gave it one last try without success. No worries I have it working on a VPS. Fly.io looks like a great option for apps that listen on port 80 and 443, but maybe not yet ready to work over random ports.
This is definitely supported. Are you sure your umbrella apps are listening on 0.0.0.0? If they’re listening on 127.0.0.1 our proxy won’t be able to connect to them.
Hi Kurt. Yes everything is listening on 0.0.0.0. If someone at Fly would like a sample umbrella app for regression testing or customer education, I’ll help write one for you. Otherwise I’ll stick with my VPS.
Can you post the contents of your fly.toml file?
One other thing to note is that, as far as I know, the default
<appname>.fly.dev domain will always use https in the browser, even if you type http, due to browser security rules with the
This means that if you haven’t configured the ports to support TLS they won’t work in browser.
Hey @charsleysa THANKS for the
.dev tip - that could explain it. I’m only five years behind on this news. Seems my umbrella app could never work on Fly with the default TLD.
fly.toml is on Github.
You can probably do
https on port 80 (and any other weird port). I haven’t tested it, but the
.dev TLD just enforces TLS, it doesn’t always redirect people to 443.
I’ve made a PR in Github Update fly.toml by charsleysa · Pull Request #7 · andyl/phoenix_live_editable · GitHub
This should achieve what you’re trying to do. Essentially if you want to use the
.dev TLD you need all your ports to handle TLS.
Luckily the fly proxy that handles the request can do the TLS stuff for you then hands your app a basic http connection.
You’ll notice that I added the TLS handler to all the 808x ports. This means that you’ll always have to use https to connect to your app, http won’t work.