In the previous post, we introduced how to host a webassembly application on azure storage. In this post, we'll introduce how to enable HTTPS and custom domain for your application.
1. Eable HTTPS
Azure storage doesn't support HTTPS protocol. You need use Azure CDN to enable HTTPS. Login to azure portal, oepn your storage account, select
on the left panel, create a new CDN endpoint:
Origin hostname is pointed to the static website.
After CDN endpoint is created, click it, you should see the
Endpoint hostname on the right side. It should be an https url:
Open the url in the browser, you should see your applicaion.
2. Redirect HTTP to HTTPS
HTTP is not secure. You can redirect all HTTP requests to HTTPS endpoint. Select
Rules engine on the right side, click
Add rule on the top,
Request Protocol and
Url Redirect like this:
After saving, use http protocol to access your CDN endpoint, you should be redirect to https protocol.
3. Add custom domain
Custom domains on the right side, and click
+ Custom domain on the top:
You should be navigated to a page where you can add custom domain:
Before adding your domain, you need go to your domain provider, add a
CNAME record of your domain pointed to your CDN endpoint. Like in this example,
our domain is
www.devtest.pm, our endpoint host name is
myappdevtest.azureedge.net, so we add a
CNAME record in your DNS like this:
After domain added, click it, you can enable HTTPS for your custom domain:
Certificate management typ as
CDN managed, Azure will create a SSL certificate for your domain and will renew it automatically. All these
The whole process might take 5 to 10 minutes. When it is done, you should be able to access your website via your domain.
4. Enable custom root domain
Enabling root domain, like
xxxx.dom instead of
www.xxx.dom, is more complex. Because azure doesn't support issuing SSL certificate for root domain.
You need create a SSL certificate by yourself and upload the certificate to azure. I don't want to make this post too long. Let's leave this topic to
the next post.