Hello!
I’m having trouble serving a Phoenix application to a custom domain appropriately behind Fly’s reverse proxy.
I have generated certifications for the root domain and the wildcard domain, and I can actually ‘make’ the domain work if I give my OTP application the following configuration at compilation in its production environment:
config :my_app, MyAppWeb.Endpoint,
...
force_ssl: [
host: "example.com:443",
rewrite_on: [:x_forwarded_host, :x_forwarded_port, :x_forwarded_proto]
]
… which is fine, but if I understand what’s happening right, this seems like it’s brittle; I thought the configuration was going to be something like this, instead:
config :my_app, MyAppWeb.Endpoint,
...
force_ssl: [
rewrite_on: [:x_forwarded_host, :x_forwarded_port, :x_forwarded_proto]
]
… which does serve appropriately to my_app.fly.dev
, but not to the custom domain.
Any help at all is greatly appreciated!
(For what it’s worth, I’m willing to embrace the idea that I should actually manually set the force_ssl[:host]
configuration if that’s right! I think I need a sanity pass on that more than anything, though, for someone more versed in this stuff to give me the green light to do that!)