local build from commit 3af15c0725605162dc8dad0c6ab241e2dc4553c6
alpine 3.12.0 docker container
./caddy run --config Caddyfile
FROM alpine:3.12.0 ENV CADDYPATH=/etc/.caddy WORKDIR /app COPY . . RUN apk add nss-tools EXPOSE 80 443 CMD ["sh", "./run.sh"]
:443 tls internal encode gzip log file_server rewrite / /AMAG.Auth reverse_proxy /AMAG.Auth* http://host.docker.internal:7325 reverse_proxy /AMAG.Portal* http://host.docker.internal:7326
When I try to access the site I get a “too many redirects” browser error. Using the dev tools, I can see I’m generating an infinite loop of 308 redirects to my URL – https://dev.1fsilo.com redirects to https://dev.1fsilo.com, etc. Please note this URL is on an intranet and won’t be reachable for anyone outside our company.
No error messages in caddy logs. Firefox gives something like this:
“Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”
Chrome gives something similar.
- Specified the site name in Caddyfile
- Used wildcard on port 443 (as in above Caddyfile)
- Added reverse_proxy directive to localhost:443
- Tried to figure out how to eliminate the “rewrite” directive in above Caddyfile thinking that may be the culprit. I don’t see a way to do this, though, as I need “/” to redirect to “AMAG.Auth”. I can just reverse_proxy / http://host.docker.internal:7325 to pull up the index.html file, but then I get 404s on all my requests for css, images, and js – those requests need to be forwarded to “AMAG.Auth” as well.
There’s a load balancer or proxy in front of Caddy in this case, and ordinarily I’d blame that but this worked with Caddy 0.x so that can’t be the whole story. I guess I’m wondering what’s different between Caddy 0.x and Caddy 2 that might cause this kind of redirect loop? Is this plausibly being caused by the rewrite directive or does it seem like the issue might be upstream of that?
Not sure how much help anyone can give me given the lack of information I have about the proxy we have in front of Caddy, but any help at all is greatly appreciated.
Edit: I just saw another “Too many redirects” post from Dec. that I hadn’t been able to find searching, looking at that now.