When creating an app, via the fly.toml spec.
Is it possible to give it an alias so that I can more easily query apps by using the internal http requests to app-name.internal:port?
For example in the fly.toml app the name is:
lumberjack-sticky-1182
And the alias can be:
comfyui_server
I would then like to be able to call the comfyui_server.internal:8143 to make http calls to lumberjack-sticky-1182, because having aliases will drastically simplify our deployment workflow.
I am working on an opensource application, and the auto-generated names for fly machines will require our deployments to use custom api requests instead of the normal flyctl if this isnt possible.
Doesn’t this require the app name to be a unique identifier for the entire platform?
Like 2 different accounts can’t both have an app named “hello” for example, I assume that the name of the app is the unique identifier as well, so we can’t have 2 apps with the same name.
I am trying to have my 1 app communicate with another app, using the appname.internal:port.
But because of how names work in fly, I can’t get my name to be something generic like “backend” or “imageapi” or “openaiproxy” because those are already taken.
And due to the nature of my project, all the code is opensource, meaning that it will require other developers to manually change the names of every single microservice & the urls they use to communicate due to the names.
I think I found a solution.
Most of my application is in python anyway, so using something like monkeypatching the backened & using simple aliasing would work, this code most likely won’t work, but here is an example I quickly got from chatgpt:
import requests
import dns.resolver
def resolve_internal_dns(name):
"""Resolve DNS for internal names with .internal TLD."""
if name.endswith('.internal'):
# Get all internal dns records
# Take the one that has the closest match aka "imageapi-blake-falcon-994" will be the one with the correct alias in this case
# return the full url back
else:
return name
# Save the original methods
original_get = requests.Session.get
original_post = requests.Session.post
original_put = requests.Session.put
original_delete = requests.Session.delete
def patched_get(self, url, **kwargs):
resolved_url = resolve_internal_dns(url) or url
return original_get(self, resolved_url, **kwargs)
def patched_post(self, url, data=None, json=None, **kwargs):
resolved_url = resolve_internal_dns(url) or url
return original_post(self, resolved_url, data=data, json=json, **kwargs)
def patched_put(self, url, data=None, **kwargs):
resolved_url = resolve_internal_dns(url) or url
return original_put(self, resolved_url, data=data, **kwargs)
def patched_delete(self, url, **kwargs):
resolved_url = resolve_internal_dns(url) or url
return original_delete(self, resolved_url, **kwargs)
# Apply the monkey-patch
requests.Session.get = patched_get
requests.Session.post = patched_post
requests.Session.put = patched_put
requests.Session.delete = patched_delete
# Example usage
try:
response = requests.get("imageapi.internal/some-endpoint")
print(response.json())
except Exception as e:
print(f"Request failed: {e}")
This is normally how it’s done. The devs would change the name by setting a config somewhere or an environment variable. It wouldn’t require any monkey patching if it’s your code.
What charsleysa said. The code snippet above won’t work, you’re still hitting <appname.internal> and your resolve DNS doesn’t really do anything, plus you may have multiple .internal apps in your org.
Just prefix your app name w/ your project, eg comfyui_server, comfyui_img