Front door 404 error

Marco Tulio Nuñez Escobedo 40 Reputation points
2023-03-30T16:16:04.3366667+00:00

I have a problem with my frontdoor, whenever i enter to my urls

https://example.z01.azurefd.net/

or my custom domain

https://customdomain.custom.com/

i'm getting 404 error

User's image

i don't see any problem, can anyone help me?

My custom domain

User's image

my route

User's image

My origin (wich points to my app service)

User's image

My route

User's image

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
621 questions
{count} votes

Accepted answer
  1. GitaraniSharma-MSFT 49,001 Reputation points Microsoft Employee
    2023-04-01T04:46:07.37+00:00

    Hello @Anonymous ,

    I understand that you are getting error 404 when accessing your Azure Front Door default or custom domain URL.

    From your screenshots, I can say that the root cause of your issue is the empty origin host header.

    Let us first understand what origin host header does. Requests that are forwarded by Azure Front Door to an origin will include a host header field that the origin uses to retrieve the targeted resource.

    For example, a request made for www.contoso.com will have the host header www.contoso.com. If the request was made for www.contoso.com, and your origin contoso-westus.azurewebsites.net has an empty header field, Front Door will set the host header as www.contoso.com.

    Most app backends (Azure Web Apps, Blob storage, and Cloud Services) require the host header to match the domain of the backend. However, the frontend host that routes to your origin will use a different hostname such as www.contoso.net.

    If your origin requires the host header to match the origin hostname, make sure that the origin host header includes the hostname of the origin.

    Refer: https://video2.skills-academy.com/en-us/azure/frontdoor/origin?pivots=front-door-standard-premium#origin-host-header

    You are using Azure App service as your backend, and you also mentioned that there is no custom domain configured on your App service. Now, if the origin host header is kept empty, the AFD will forward the request including a host header as your custom domain, but it is not configured on your App service and hence it will not match with your App service domain and eventually fail with 404 not found error. Because the App Service doesn't recognize the custom domain and rejects all incoming requests for this host name. It can't determine where to route the request.

    The point that you mentioned "I didn't set a host header because I want to stay on my custom domain" only applies when you've the custom domain configured on your App service as well.

    Refer: https://video2.skills-academy.com/en-us/azure/architecture/best-practices/host-name-preservation#implementation-guidance-for-common-azure-services

    If you don't configure the custom domain in your backend and just keep the Azure Front Door origin host header empty, it just overrides the host name, which can lead to various issues as described in the below section:

    https://video2.skills-academy.com/en-us/azure/architecture/best-practices/host-name-preservation#why-you-might-be-tempted-to-override-the-host-name

    The proper guidance here is to make sure you configure both the backend and AFD to preserve the host name. And to do so, you need to configure the custom domain in your App service and then keep the Azure Front Door origin host header empty. This way, when the AFD sends the request with the custom domain, the App service will be able to recognize the incoming request with the host name and will accept it without any issues.

    To fix this issue, you can either add the origin host header as your App service URL.

    OR

    Configure the custom domain in your App service and keep the rest of configuration as it is.

    Kindly let us know if the above helps or you need further assistance on this issue.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful