0
votes

I am using Azure DNS for a website that I have migrated to hubspot. I have created a CNAME record from www.mydomain.com to the hubspot hosted website. As described in this document

I am looking to also redirect the Apex domain mydomain.com to the hubspot hosted website. However I do not have a hubspot IP Address only a CNAME endpoint. How can I redirect mydomain.com to the hubspot domain without an IP Address.

1
This is tricky. You may additionally need to configure the A record for the domain name. When you configure custom domain it provides instructions to configure A record. Or additionally you can configure awverify.www.domain.com record along with awverify.domain.comlazy
Kiran I hope you don't mind but I have rewritten your question to make it a little clearer what you are asking. If you disagree with the edit feel free to roll it back.Michael B

1 Answers

1
votes

The problem you're having is an issue with the rules of DNS, which forbid a CNAME record where another record exists. The naked address (or Apex) example.com already has two records (the SOA and NS) so a CNAME is not allowed.

If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types.

In order to create an Apex record, i.e. example.com you need to use an A record, which means it needs to point to the IP of your Azure website. Once you have that you can then create a CNAME from www to example.com. (this is the supported method - your IP Address for Azure websites is static)

the command you are looking for, would be something like

$rs = New-AzureRmDnsRecordSet -Name "@" -RecordType A `
       -ZoneName example.com -ResourceGroupName $RG `
       -Ttl $ttl -Force -Overwrite
Add-AzureRmDnsRecordConfig -RecordSet $rs -Ipv4Address $IPAddress
Set-AzureRmDnsRecordSet -RecordSet $rs -Overwrite

then

$rs = New-AzureRmDnsRecordSet -Name "www" -RecordType "CNAME" `
      -ZoneName "something.com" -ResourceGroupName "DNSRecords" `
      -Ttl 60 -Overwrite -Force
Add-AzureRmDnsRecordConfig -RecordSet $rs -Cname "example.com"
Set-AzureRmDnsRecordSet -RecordSet $rs -Overwrite

If you don't have an IP address to point your apex A record to then the only solution you have is to use an IP address that will provide HTTP redirect for you.

The simplest way I can think of doing this would be to create a small Azure Web App and use that IP Address to send a HTTP status 301 Moved Permanently header. This would place negligible load on the server because it wouldn't actually be serving any pages.

An alternative would be switching to a DNS provider that does provide apex CNAME (or at least a workaround to provide similar functionality)

There are also some HTTP redirect services (both free and paid) at the end of a search (However I've never used any of these so I can't comment on the quality!)