Setup secure www as canonical domain

I’m trying to set up www.mydomain.com as the canonical domain, and have the apex domain redirected, and also non HTTP redirected to HTTPS, so in full:

https://www.mydomain.comhttps://www.mydomain.com
https://mydomain.comhttps://www.mydomain.com
http://www.mydomain.comhttps://www.mydomain.com
http://mydomain.comhttps://www.mydomain.com

No other subdomains available. I’ve tried various settings, but can’t get this working.

You’ll need to do these redirects at an app or webserver level.

If you’re using say Rails, it’ll have an option to redirect non SSL requests to SSL (you may need to get it to pay attention to the x-proxy forward header so it can figure out the original request address).

Another option (this is what I do) is to setup some S3 buckets with redirects enabled on them then point the domain names that you want directed to them.

1 Like

I’m also looking to do the same thing. Historically I’ve done this with nginx, but it’s not possible with fly.

Doing it at the application level is tricky, because I don’t want it done with the .dev domain, but do with the “live” domain.

So flyissueddomain.fly.dev should not redirect to www but my domain.com should.

A canonical way to do this in fly.toml would be really helpful.

2 Likes