In part 1 of this blog post we have set up our WordPress website and made sure it can only be accessed via HTTPS. In this part we are going to link our newly created website to a custom domain name.
Prerequisites
In order to use a custom domain name for your website you must own one. There are many organisations that will help you buy a domain name, like GoDaddy. I used TransIP for this. It does not matter from which company you bought your domain name, as long as you have full control over the DNS records.
Setup steps
To set up your custom domain, follow the following steps:
- go to the
app service
MagicAzureWebsite in your azure portal - select the
custom domains
tab - select the Add custom domain text that is somewhat hidden. It is highlighted with a red circle in the next picture
- Now you can type in your desired domain name. This can be your entire domain (like magicazure.com), or a subdomain (like website.magicazure.com or www.magicazure.com). You can repeat these steps if you want your website to react to both at the same time.
- Now press
validate
- Of course validation will fail, since we have not proven to Azure we own the domain. This is no problem. At the bottom you will see the expected DNS records.
- For a sub domain azure will expect a TXT record and a CNAME
- For the whole domain Azure will expect a TXT record and an A record.
- You can add the desired record to your DNS settings. Best do this in a different browser session and leave your Azure page open.
- After you finished the previous step you can try to press validate again. It might take some time, but in my experience Azure identifies the updates immediately.
- Do not forget to press the
Add custom domain
button.
By following these steps, your custom domain name is linked to your website. However, you will see the website being identified as not secure.
Add the certificate
In order to make the website accessible via HTTPS we need a certificate. Normally a certificate will cost you money. Furthermore, most certificates are only valid for a limited duration. Luckily there is a free (as in no extra money) way around this.
- In the Azure portal go to the
app service
again - Check the tab
TLS/SSL settings
- At the top, select the
Private Key Certificates (.pfx)
- Now an option will appear where you can select
Create App Service Managed Certificate
- You can select the custom domain name you created above and then press
create
- After a few minutes a certificate is created for you. However, this certificate is not yet used by our website. We have to go back to the
Custom domains
tab - Next to our custom domain name we can select the
Add Binding
text. - In the new pop-up we select
- Our custom domain name,
- The Private Certificate we just created that has the same name as our custom domain name
- The TLS/SSL type. I could only select
SNI SSL
- Press
Add Binding
After all these steps, our website is accessible via HTTPS with a valid certificate.