Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix Too Many Redirect error using Caddy + Cloudflare

On Cloudflare, go to Crypto -> SSL and set it to Full or Full(strict)

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 your@email.com
}
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
FROM node:6-onbuild
EXPOSE 3000
/* 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');
});
@Keda87
Copy link

Keda87 commented Dec 26, 2021

thanks!! my issue fixed after change my SSL settings in cloudflare into Full(strict)

Do you know, why this happened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment