I am hosting a nodejs server with a static site in a docker container on fly.io.
I own a domain that i purchased through hover.com, and i set up the DNS records as such:
@user84 Does the your Fly dashboard give you the green light on your certificate DNS validations? That _acme-challenge entry doesn’t look complete to me — I would have thought you’d need two entries there for _acme_challenge.www.mydomain.com and _acme-challenge.mydomain.com for all your URLs to work correctly.
Sorry i mean to reply to my own… i had a cert for *.mydomain.com, but i also needed one for mydomain.com. Honestly not sure why that fixed it but it did!
Is this still the nodejs app you’re referring to? If it is you’d probably want a middleware that checks the protocol and redirects if it’s http. But this will need to be some kind of behaviour change either way.
I have the opposite of this persons problem. I have a custom domain working at example.com, but I want it to work with the “www” as in "www.example.com". So I want both to work.
Scenario
• Running a Phoenix 1.6 application with Postgres
• I have everything running with very little configuration. So far so good.
Question
Does my Phoenix or Elixir application need to be configured to interpret “www”?
Do I need to add anymore information to my DNS provider so that if someone types “www.example.com” it will be directed to. Right now “example.com” works but I want “www” to work.
At this point wait until things have propagated 5 - 15 minutes.
You will know things are working because your certificates are valid and you should be able to visit your custom domain at example.com without the www.
My Understanding
Here is a screenshot of what my final records and record types looks like. (The value column has dummy data but the entries should help anyone understand how the records could be set up.)
Everything highlighted are the records I had to add from the flyio steps mentioned in the steps above (2 A Records, 1 AAA Record, 2 CNAME Records)
In order to get it to work with the www you need to create a CNAME record that points to your root domain. Most of my problem was a result of the CNAME | WWW | record not containing the value of my root domain example.com.
If anything looks incorrect let me know. Hopefully this helps anyone.
Verifying through the terminal
> host www.example.com
www.example.com is an alias for example.com.
example.com has address 66.255.125.99
> host example.com
example.com has address 66.255.125.99
@alenm Thanks for your comment. I managed to get my custom domain at GoDaddy to point to my app hosted on fly in no small part due to your comments above. So, thanks gain.
Not sure if you have any idea how to accomplish the following:
For services configured in fly.toml, there’s a force_https parameter that can be set to true. To redirect non-www to www, that’s not something at Fly can do directly.
Your options would be…
Handle it in your application with some sort of middleware.
Put a webserver like Caddy or Nginx in front of your app and configure the redirect there – this can be another Fly app that talks to your main app over the internal network.
Put Cloudflare in front of your Fly app and use Page Rules to enforce the redirect.
Thanks @brian one quick follow-up question. So, the reason I wanted it to resolve to www. was because I noticed that in places such as nytimes.com it does resolve to www. and was wondering if that is necessary for say SEO purposes or if I leave it as is per my previous comment then if it will negatively impact me from an SEO standpoint.
It took me a few tries to get everything working and now I have CI/CD setup and except for the resolving to www. all seems well so if I do not have to fiddle with this anymore then I’d prefer that.