Azure Application Gateway - 502 Bad Gateway error

Huy Sy Doi 20 Reputation points
2023-02-02T11:00:51.8766667+00:00

Hi Supports,

Currently we are setting up an Azure Application gateway on our kofaxtst.onmicrosoft.com system. The Backend health is good with with 200 Status for the Https protocol.

However, when we try to access a simple .htm web page hosted on a VM backend from Application Gateway Public IP Address using HTTPs protocol with port 443, the browser shows this error:

 502 Bad Gateway

 Microsoft-Azure-Application-Gateway/v2

We are making sure that we are able to access the simple .htm web page hosted on a VM backend by using the public IP address of the VM.

Could you please advise what we should double-check to address this error?

Thanks very much!

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,213 questions
{count} votes

Accepted answer
  1. GitaraniSharma-MSFT 50,021 Reputation points Microsoft Employee Moderator
    2023-02-07T12:36:29.96+00:00

    Hello @Huy Sy Doi ,

    Apologies for the delay in my response as I was checking all the configuration and also trying to reproduce this setup in my lab.

    So, below are my findings:

    For the TLS connection to work, you need to ensure that the TLS/SSL certificate meets the following conditions:

    When you enable end-to-end SSL on Azure Application gateway v2, below is the live traffic behavior:

    If the backend pool address is an IP address or hostname isn't set in HTTP settings, SNI will be set as the hostname from the input FQDN from the client and the backend certificate's CN has to match with this hostname.

    Refer: https://learn.microsoft.com/en-us/azure/application-gateway/ssl-overview#for-live-traffic

    Also, if you check the below doc, it says the Common Name (CN) of the backend certificate should match the host header of the custom probe.

    https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-backend-health-troubleshooting#backend-certificate-invalid-common-name-cn

    Now, in your setup, the certificate used by you has a Common Name (CN): kofax-VN01CSUC17-CA and this is added correctly in your custom health probe (as I can see from the screenshot shared by you before) but you are trying to access the Application gateway with its IP address which doesn't match the CN of the backend certificate.

    And hence, you are seeing the backend healthy, but the Application gateway is failing with error 502.

    To fix this issue, my recommendations are as below:

    1. Point your Application gateway's IP address to domain "kofax-VN01CSUC17-CA", if possible and use the same to access the App gateway.

    OR

    1. If it is not possible to point the Application gateway, then try a hostname override in your backend HTTP settings to "kofax-VN01CSUC17-CA" as below and check if it works.

    User's image

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.