I created an Azure static website following Microsoft's tutorial. Everything works, except that Azure doesn't return the 404.html
page for HTTP 404 requests.
My static website settings:
When I navigate to a page that doesn't exist, these are the headers Azure returns:
HTTP/1.1 404 The requested content does not exist.
Content-Length: 1214
Content-Type: text/html
Server: Windows-Azure-Web/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code: WebContentNotFound
x-ms-request-id: 2680e62d-a01e-002a-7d48-de2087000000
x-ms-version: 2018-03-28
Date: Sat, 08 Feb 2020 06:25:27 GMT
Those headers are correct. But here's what shows in the browser:
I've verified that my 404.html
page works fine by navigating directly to that page:
If I use the 'Storage Explorer' I can also see that my 404.html
file is in $web
:
Yet Azure doesn't return that page for HTTP 404 errors.
Things I tried:
- Different browsers (Firefox and Chrome). Got the same result.
- Emptied browser cache.
- Re-uploaded the 404.html page.
- Searched online for people with the same problem (didn't found any).
- Verified my static website settings against several online tutorials. It seems my settings are correct.
Update: Following Biren's suggestion I set the $web
container to the 'Container' access level. After re-uploading my files the issue still remains. But the text in the browser looks different now:
These are the returned HTTP headers for files not in the blob (unchanged from earlier and still proper 404 from what I can tell):
HTTP/1.1 404 The requested content does not exist.
Content-Length: 966
Content-Type: text/html
Server: Windows-Azure-Web/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code: WebContentNotFound
x-ms-request-id: 6bfc762c-b01e-0026-1113-dfb78f000000
x-ms-version: 2018-03-28
Date: Sun, 09 Feb 2020 06:38:03 GMT
Best Answer
I fixed the issue myself today. The software I use to upload my website by default Gzips every HTML file. This is pretty standard and good behaviour. Unfortunately, Azure Blob Storage 404 pages do not support Gzip encoding.
This limitation isn't documented, although there's a feedback request for Gzip encoding of 404 pages here.
So the solution is simple: when uploading the static website, Gzip all HTML pages except
404.html
. As soon as I did that, my strange text on 404 pages disappeared and everything works fine now.