I’m trying to make it so that my
fly.io app redirects:
My app SSL config: (
fly.io doesn’t give you file access to your key/cert, so I’m not sure what to put in those, if I get rid of them things seem to work fine?)
My SSL cert is all good:
As for the redirection of www to the apex domain, I wrote this myself and it didn’t work. I then tried using GitHub - remi/plug_canonical_host: PlugCanonicalHost ensures that all requests are served by a single canonical host., but that doesn’t work either. I’m not sure if I’m doing something wrong or if
fly.io is doing some automagical stuff in the background I’m not seeing.
Fly terminates SSL at the proxy, so you should only need to configure:
force_ssl: [rewrite_on: [:x_forwarded_proto]]
For the canonical host, if you can share what you wrote, I could comment further, but a simple plug should do the job just fine
Ah, so the Fly proxy handles all SSL? So should I get rid of all of the Phoenix-specific SSL/HTTPS config?
Once I do that, the HTTP → HTTPS part works, though the www redirect does not.
config/prod.exs: (I made sure to use
flyctl secrets set CANONICAL_HOST=nezteb.net)
UGH literally as I uploaded that last screenshot, I realize that I didn’t change the app name in the function:
:my_app # should have been :nezteb...
Now things seem to be working. Thanks Chris!