If you’re reading this, you may have noticed that you’re currently on petermorlion.com, the address of my blog. It’s a custom domain, served over SSL. Behind the scenes, I’m running the Ghost blogging software on Azure, with Cloudflare in front of it all. I recently had to set this all up again (due to updating Ghost), so I thought I might document the necessary steps.
Setting up Ghost on Azure
Setting up Ghost on Azure is quite simple. Ghost doesn’t run out of the box on an Azure Web App, but thanks to Felix Rieseberg, you can still deploy it with a single click. His Ghost-Azure project is an up-to-date version of Ghost that runs on Azure. Simply click on the “Deploy to Azure” button, fill in the details and let it do the work.
After this, you have a running instance of Ghost and can fill in the details or start posting. But it still runs on an
azurewebsites.net subdomain, i.e.
myblog.azurewebsites.net. You might want that to be
www.myblog.com. But the extra thing I wanted, was to add Cloudflare to the mix.
Setting up a custom domain with Cloudflare
First, you need to point your domain to the Cloudflare nameservers. Log in to your domain name registrar and change the nameservers to those of Cloudflare. This is what my configuration looks like:
Never mind any DNS records at your registrar, as we’re going to set that all up in Cloudflare. Go to Cloudflare and select the DNS tab. Now point an A-record of your domain to the Azure servers. You can find the IP address in the Azure portal under the Custom Domains tab of your Web App:
You’ll also need a CNAME-record making
www an alias of
myblog.azurewebsites.net. Finally, add a TXT-record containing the Azure IP address. We only needs this to prove ownership of the domain. We’ll be removing the TXT-record later.
This is what my final Cloudflare configuration looks like (note that I have already removed the TXT-record):
Now let’s add the domain in Azure. In the Custom Domains tab of you Web App in the Azure portal, click on the
Add hostname button and fill in the domain name. Click on
Validate and it should be ok if you’ve set up all the DNS records correctly (DNS propagation might take a while though). Then click on
Add hostname. Do this for both an A-record and a CNAME-record. Again, DNS propagation might take a while, but after a certain amount of time, you should be able to navigate to your custom domain.
One final thing to check is if you have an application setting named
url which has your custom url as value (e.g. www.petermorlion.com). The readme on Felix’s repository mentions
websiteUrl, but for me it seems to have to be
url (though I added both to be sure).