We run several static web apps on azure and we’d like to put a simple reverse proxy in front of them to redirect the traffic depending upon the url.
If I host this on my personal VPS then everything seems to work as expected but on Azure, it all changes. I’m running Caddy on an Azure Container Web App and I’m getting constant failures due to having too many redirects.
2. Error messages and/or full log output:
Too Many Redirects
3. Caddy version:
2.7
4. How I installed and ran Caddy:
Running via a docker file:
FROM caddy:2.7
COPY Caddyfile /etc/caddy/Caddyfile
a. System environment:
Azure App Container (Docker)
c. Service/unit/compose file:
FROM caddy:2.7
COPY Caddyfile /etc/caddy/Caddyfile
Shows a permanent redirect. My guess is that Azure decides to route the traffic internally (not https) and Caddy tries to redirect to https. I’m fairly new to this though and am pretty stumped.
Worthwhile to add that if I change the Caddy file from www.domain.com to :80 then everything works ok. Hence my thoughts about early TLS termination on the Azure container app.
It looks like something is standing in front of your Caddy (maybe Azure LB?) and then passing all the traffic to Caddy via HTTP rather than HTTPS port. Which makes Caddy respond with HTTP-to-HTTPS redirect.
So this now results in a 502 error. I have it working if I do this without the disable_redirects and listening on 80 rather than a specific domain.
Why would this adding auto_https disable_redirects cause a 502?
Without auto_https disable_redirects, Caddy creates an automatic HTTP listener. With that directive, I believe, it only creates HTTPS listener. Try this:
You need to check your Azure configuration. To me, it looks like you have Azure LB standing in front of Caddy. With you redacting your website and IP, I can’t say much. Everything is just a guesswork.