Back to Blog
Jul 26, 2023

ERR_TOO_MANY_REDIRECTS with Azure App Services and Cloudflare

Written by Zack Schwartz

Introduction

In some of our hosting R&D, we put up an instance of the Raytha platform on Azure Web App for Containers, which is a product of Azure App Service. However, we like to handle all of the SSL and https with Cloudflare, which serves as a reverse proxy.

Now the website loads fine when you go to the fully qualified domain that Azure Web Apps provides you, which looks something like mywebsite.azurewebsites.net. It has the SSL enabled and everything. But when we added our custom domain and routed traffic to our site from Cloudflare, we get the dreaded ERR_TOO_MANY_REDIRECTS.

Azure App Service Infinite Loop for Http / Https Redirection

The problem is being caused by the fact that SSL for our custom domain is being handled by Cloudflare, but when we add it to the Azure App Service side, it considers it non-SSL. By default, Azure App Service's settings are set to redirect Http to Https. As a result of this, it finds itself in an infinite redirect loop.

Fix Too Many Redirects With Azure App Service and Custom Domain

If the above scenario applies to you -- meaning you use a reverse proxy in front of your azure app service website to handle SSL, and you added a custom domain with no binding in your Custom Domains settings in your azure website, then you can fix it by going to your Configuration > General Settings in your azure app service and turn off Https Only as shown below.

 

picture of the author
Zack Schwartz @apexdodge

ENTREPRENEUR & SOFTWARE ENGINEER, AUSTIN, TX
I enjoy tackling a wide array of business challenges ranging from front line product support and operations to sales and marketing efforts. My core expertise is in software development building enterprise level web applications.


Subscribe to the Raytha newsletter