Azure Application Gateway 502 Errors - No IP Address Resolved

Greg Pringle 0 Reputation points
2023-03-23T17:38:44.08+00:00

I am trying to setup azure application gateway connected to an azure static web site, both using https.

I can connect to the backend static website successfully using https.

I have everything configured as well as I can tell but when I access the external domain name I get a 502 Bad Gateway with our certificate showing correctly saying the site is secured.

Running "diagnose and solve problems" I get this:

We ran several diagnostics on your resource Portal-Gateway-Test and have found the below issues that could be the cause of your Bad Gateway Error (502). Issues Identified No IP Address Resolved: The host 'https' does not resolve to any IP Address.Please ensure you have entered the correct URL.

I can't figure out how to make this work please help.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
962 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
770 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GitaraniSharma-MSFT 47,676 Reputation points Microsoft Employee
    2023-03-24T12:07:16.3+00:00

    Hello @Greg Pringle ,

    Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

    I understand that you are trying to setup Azure Application gateway with an Azure static web app as backend and have configured end-to-end SSL where both uses HTTPS. You are able to connect to the backend static website successfully using https but when you access the external domain name, you get a 502 Bad Gateway with issue identified as "No IP Address Resolved: The host 'https' does not resolve to any IP Address".

    If I understood your setup correctly, you've setup the Application gateway with the static web app as the backend pool and have configured a custom domain in your static web app which is not mapped to the Application gateway. And you are trying to access the Application gateway with that custom domain/external domain name. Please correct me if my understanding is wrong.

    Refer: https://learn.microsoft.com/en-us/azure/static-web-apps/custom-domain

    If you have set up a custom domain in your Static web app, you also need to make sure that the custom domain is mapped to the IP address/DNS name of your Application gateway for it to resolve the domain correctly.

    You can refer the below tutorial which shows the custom domain setup for an App Service with Application Gateway (Static web app also requires similar setup).

    https://learn.microsoft.com/en-us/azure/application-gateway/configure-web-app?tabs=customdomain%2Cazure-portal

    As you can see in the configuring DNS section, DNS is relevant in two places:

    • The DNS name, which the user or client is using towards Application Gateway and what is shown in a browser.
    • The DNS name, which Application Gateway is internally using to access the App Service in the backend.

    To route the user or client to Application Gateway using the custom domain, set up DNS using a CNAME alias pointed to the DNS for Application Gateway. To find the Application Gateway DNS address, please refer: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-faq#where-do-i-find-the-application-gateway-ip-and-dns. Alternatively create an A record pointing to the Application gateway IP address directly. (For Application Gateway V1 the VIP can change if you stop and start the service, which makes this option undesired.)

    App Service/Static web app should be configured so it accepts traffic from Application Gateway using the custom domain name as the incoming host. For more information on how to map a custom domain to the static web app, refer: https://learn.microsoft.com/en-us/azure/static-web-apps/custom-domain-external

    More information about such type of setups can be found in the below doc for your reference:

    https://learn.microsoft.com/en-us/azure/architecture/best-practices/host-name-preservation#implementation-guidance-for-common-azure-services

    Once you make sure that both your Application gateway and Static web app are configured to resolve to the custom domain, you should be able to access the external domain name without issues.

    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.