New Feature: Automatic HTTPS redirects

Who doesn’t love a new feature? It’s now possible to configure HTTP → HTTPS redirects through fly.toml . Enabling it will return a HTTP response with a 301 status code and a redirect to the HTTPS standard port.

[[services.ports]]
  handlers = ["http"]
  port = 80
  force_https = true

An example response

HTTP/1.1 301 Moved Permanently
location: https://example.fly.dev/
...
...

All in a day’s work!

We’ve designed this feature with the most common use case in mind. It does not support redirecting to custom HTTPS ports, returning a different status code or redirecting specific requests. Our recommendation is to implement these in your application .

Happy HTTPS redirecting!

21 Likes

This is great!
Thank you so much for listening, once again, and shipping features quite fast.

1 Like

Awesome! Thanks Fly team! :tada:

1 Like

That’s very very useful, saved more than a days work!

3 Likes

this seems to work well when not redirecting from custom domain. But I found problems when using a godaddy domain of .com type. Maybe is just misunderstanding from my part, but I don’t really know how to solve this. Can you, or anyone else provide a way to force https in all parts, since when using http my applications does not work?

Awesome feature, I would like to know if it is possible to do this for WWW to NON WWW redirects (https:www.myapp.fly.dev → https:myapp.fly.dev), since it is affecting the SEO of my page, or if there is any other alternative (I tried with NGINX but I’m neither quite sure since I do not own the domain name). Thanks in advance!

This is not working for me. I’m getting “Blocked loading mixed active content” errors and my page just shows up blank. Here is my fly.toml entry for http_service:

[http_service]
internal_port = 8080
force_https = true
port = 80
handlers = [“http”]
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = [‘app’]
protocol = “https”

If anyone has any ideas I would really appreciate it. I’m fresh out now as I’ve been dealing with this for the past week.

“Blocked loading mixed active content” is likely coming from your web browser. You may have images, CSS files and/or other external asserts from http://..., while the page itself is served from https://....