On Cloudflare, go to Crypto
-> SSL
and set it to Full
or Full(strict)
Last active
January 27, 2025 10:21
-
-
Save lopezjurip/5314252970cc94970058320ac78f490a to your computer and use it in GitHub Desktop.
Fix Too Many Redirect error using Caddy + Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
www.mysite.com, mysite.com { | |
proxy / webapp:3000 { | |
proxy_header Host {host} | |
proxy_header X-Real-IP {remote} | |
proxy_header X-Forwarded-Proto {scheme} | |
} | |
gzip | |
tls [email protected] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy: | |
image: zzrot/alpine-caddy | |
restart: always | |
ports: | |
- 80:80 | |
- 443:443 | |
links: | |
- webapp | |
volumes: | |
- ./Caddyfile:/etc/Caddyfile | |
- ./.caddy:/root/.caddy | |
webapp: | |
build: . | |
restart: always | |
environment: | |
- NODE_ENV=production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:6-onbuild | |
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint no-console:0 strict:0 */ | |
'use strict'; | |
const express = require('express'); | |
const path = require('path'); | |
const morgan = require('morgan'); | |
const app = express(); | |
app.use(morgan('combined')); | |
// serve static assets normally | |
app.use(express.static(`${__dirname}/public`)); | |
app.get('*', (request, response) => { | |
response.sendFile(path.resolve(__dirname, 'public', 'index.html')); | |
}); | |
app.listen(3000, err => { | |
if (err) console.error(err); | |
console.log('Web app listening on port 3000'); | |
}); |
This worked for me as well.
Also worked for me as well :) Thanks!
Thanks! Working perfectly with this change. I thought i had gone crazy testing caddy as an LXC as well as a docker container, but with nothing working.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just want to +1 that changing my SSL settings at
https://dash.cloudflare.com/{user-id}/{domain}/ssl-tls
toFull
fixed the "Too many redirects" issue immediately!Thank you for putting this guide up! I assume it's due to Let's Encrypt and Caddy's own SSL certificates.