Skip to content

Instantly share code, notes, and snippets.

@liesislukas
Forked from lopezjurip/Caddyfile
Created March 18, 2024 07:19
Show Gist options
  • Save liesislukas/7795b5cda2b440d4f23a28f6ca5b460d to your computer and use it in GitHub Desktop.
Save liesislukas/7795b5cda2b440d4f23a28f6ca5b460d to your computer and use it in GitHub Desktop.
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment