A community member has associated this post with a similar question:
"502 Bad Gateway" on Application Gateway when "Override with new host name" is disabled, redirect issues when enabled

Only moderators can edit this content.

"Why does Azure Application Gateway return a '502 Bad Gateway' when 'Override with new host name' is disabled, and how to fix URL redirection after login?"

Muhammad Elzedy 0 Reputation points
2024-09-28T16:04:55.4833333+00:00

Hello,

I am setting up an Azure Application Gateway to route traffic to an Azure App Service, which is currently accessible via aladwaa360.azurewebsites.net. I have also configured a custom domain for the gateway: staging.example.com.

Issue 1: "502 Bad Gateway" with Host Name Override Disabled

When I access the Application Gateway's public IP, I receive a "502 Bad Gateway" error if the 'Override with new host name' option in the backend settings is set to No. I'm not sure why this happens, as I expected the traffic to forward to my app service correctly.

Issue 2: URL Redirection Problem with Host Name Override Enabled

When I enable the 'Override with new host name' option, the gateway works and routes traffic correctly to my app service under the custom domain staging.example.com. However, there is an issue after logging in to the app.
The app service has a login form that redirects users to another application hosted at staging.account.example.com/login. After successfully logging in, the user should be redirected back to staging.example.com, but the URL changes briefly to staging.example.com and then quickly switches back to the app service's default domain, aladwaa360.azurewebsites.net.

Goal:

  • I want to ensure that after logging in, the URL remains as staging.example.com without switching back to the default app service domain. I also plan to route traffic based on the URL path to different backends (e.g., traffic to /qrcode should go to another app service).

Questions:

  1. Why does the "502 Bad Gateway" error occur when the "Override with new host name" option is disabled?
  2. How can I fix the redirection issue so that the browser stays on the custom domain staging.example.com after logging in, without redirecting to the app service's default domain?
  3. What is the best way to configure path-based routing in the Application Gateway for different backend services?

Thank you in advance for your help!

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,381 questions
0 comments No comments
{count} votes