HermanMartinus / bearblog

Free, no-nonsense, super fast blogging.
MIT License
2.7k stars 77 forks source link

problems connecting custom domain #71

Closed anthay closed 3 years ago

anthay commented 3 years ago

Hi Herman. I followed your instructions to set CNAME and TXT records for my domain name. I waited an hour and tried looking up the records using https://toolbox.googleapps.com/apps/dig/?lang=en#TXT/. The CNAME record was correct, but the TXT record query also returned the CNAME record. (And when I clicked save I got the "TXT record for '50percentbanana.com' has not been set" message.)

I talked to Namecheap support. They told me:

"Both, CNAME and TXT records are set up for your domain name properly. However, as the CNAME has the highest priority, it affects other records that are set up for your domain name (with the host @). Thus, the TXT record is not reflected in Google Dig tool. In this case, you may change the CNAME record to Alias on or set up the CNAME record for www host and then configure the URL redirect for the domain itself, and redirect it to www subdomain."

So I changed CNAME to ALIAS and now typing my domain name into the URL takes me to my home page on bearblog.dev.

So are the custom domain instructions wrong? Did I do something stupid?

HermanMartinus commented 3 years ago

Ignore my last comment, I misread. It's possible to use an ALIAS similarly to a CNAME in some respects. What happened on your side (I think) is that the TXT record hadn't propagated yet. I just looked it up on google toolbox and it's set correctly now.

So changing to the A record from a CNAME record may have just given the DNS some additional time to update.

HermanMartinus commented 3 years ago
Screenshot 2021-04-07 at 17 47 47
anthay commented 3 years ago

After I'd followed the instructions on the bearblog dashboard and waited a bit the Dig query ANY showed this:

id 14466
opcode QUERY
rcode NOERROR
flags QR RD RA
;QUESTION
50percentbanana.com. IN ANY
;ANSWER
50percentbanana.com. 3600 IN SOA dns1.registrar-servers.com. hostmaster.registrar-servers.com. 1617730445 43200 3600 604800 3601
50percentbanana.com. 1798 IN CNAME shaped-krill-fusn49u0rpoovwvgh0i6za5w.herokudns.com.
50percentbanana.com. 1799 IN NS dns1.registrar-servers.com.
50percentbanana.com. 1799 IN NS dns2.registrar-servers.com.
50percentbanana.com. 1798 IN TXT "look-for-the-bear-necessities"
;AUTHORITY
;ADDITIONAL

But a TXT query showed:

id 1083
opcode QUERY
rcode NOERROR
flags QR RD RA
;QUESTION
50percentbanana.com. IN TXT
;ANSWER
50percentbanana.com. 1798 IN CNAME shaped-krill-fusn49u0rpoovwvgh0i6za5w.herokudns.com.
;AUTHORITY
herokudns.com. 9 IN SOA dns1.p05.nsone.net. hostmaster.nsone.net. 1617734472 600 900 1209600 10
;ADDITIONAL

The Namecheap support guy told me this was because CNAME for the 50percentbanana.com host took priority over any other record that was also set for 50percentbanana.com. (If I understood him correctly.) The fix was to not set a CNAME record, but to set an ALIAS record for herokudns instead.

Having changed CNAME to ALIAS a couple of minutes later 50percentbanana.com was showing the bear blog.

I know next to nothing about DNS. Presumably, the instructions work for you. I don't know if what the Napecheap support told me is coerrect. But setting ALIAS instead of CNAME worked for me. I wonderred if someone who actually understands DNS would find this uesful and, if necessary, update the instructions.

I like the platform and wish you well. A few weeks ago I thought to myself, I wish there was a dead simple way to just publish a markdown blog post. Perhaps I'll try to make something. And then I read about bearblog!

HermanMartinus commented 3 years ago

DNS work is black magic 😅 I'm glad it's working for you now, and thanks for the kind words!

pentlander commented 3 years ago

I ran into this as well, turns out you can't have a txt record with the same name as a cname: https://serverfault.com/questions/834320/adding-both-cname-and-txt-dns-records-for-one-subdomain . It looks like other services work around this by adding a static prefix to the txt record domain, e.g. for gitlab pages _gitlab-pages-verification-code.www -> www.foo.com

HermanMartinus commented 3 years ago

Hmmmm, that's inconvenient.

I haven't tested this myself, but try using an ALIAS instead of a CNAME record and see if that works. It seems to have worked for this guy

pentlander commented 3 years ago

Yep that also worked for me, it's probably worth mentioning using ALIAS in the docs. I'm not sure if it's just a Namecheap DNS thing or if it happens with other DNS providers as well, but other services (e.g. sendgrid) seem to do the static prefix as a workaround.

HermanMartinus commented 3 years ago

Gotcha. I'm glad it works. I'll add it to the docs posthaste. 👍