简体   繁体   中英

Azure CDN default document index.html

I have now successfully setup my static website in a CDN, Is there a way to specify that index.html is the default document ? It is a 1 page site I just would like to browse to the root url without having to type /index.html ..

Thank you

Based on your previous question , I am assuming that you have set CDN to map to blob storage. If this is correct, unfortunately it is not possible as of today because Azure Storage does not have a support for default document. This is one of the most requested feature on Azure Feedback - https://feedback.azure.com/forums/217298-storage/suggestions/1180039-support-a-default-blob-for-blob-storage-containers however it is still pending.

If you want, you can create a proper website (instead of having this index.html file in blob storage) and serve that website via CDN. You can find more details about it here: https://azure.microsoft.com/en-in/documentation/articles/cdn-websites-with-cdn/ .

Microsoft is working on this. At the moment you have only two possibilities to solve this:

  • Use CDN: With the premium version of Verizon you can create rules like Redirect Rules
  • Create an Web-App which act as a proxy and serves/redirects (to) blobs

Using Premium CDN If you purchased the premium version of Verizon CDN then you can create custom Rewrite rules. You'll find this in the "Advanced Features" section of your CDN endpoint. Once you click on "Manage" you will be redirected outside the portal where you can manage your cdn.

规则引擎

Hier you must create a redirect rule like this:

在此处输入图片说明 Note that each change in a rule takes about 5 hours to be activated.

To check if your redirect rule works you can install IIS and activate the URL Rewrite Module. In the Rewrite Module you can test your rules.

  1. Open IIS
  2. Open Url Rewrite Module
  3. Add Rule
  4. Add blank rule
  5. Test Pattern

Please note that if you test your pattern, it must begin with the CDN source path which is a number and your endpointname like /829292/movies.

在此处输入图片说明

Sometimes redirect rules causes problems with CDN Purging. You can solve this isssue by adding an if clause in your rule which says that redirect should only be active if it is not the purge agent.

在此处输入图片说明

This is now possible with Static websites on Azure Storage

Creating a Static Website

  1. Navigate to your storage account
  2. Select Static Website from the blade and toggle to "enabled"

    添加静态网站

  3. Once you save, this will create a URL endpoint and also a bucket named $web to host your files

    静态端点

  4. Go to your $web storage container and upload any files you want

Add CDN / Custom Domain

  1. Navigate to your CDN Profile and either Create / Edit your Endpoint
  2. Select 'Custom Origin' and use the 'Origin Hostname' that was created for your static site

    自定义来源CDN

  3. Give Azure up to 30 minutes to propagate all the settings

Further Reading

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM