How to make caddy not return 404

(Anuprita Duggal) #1

Okay so here’s the whole issue. I’m trying to get caddy to work behind cloudflare and trying to fetch letsencrypt certs for working with cloudflare

So here’s how it looks
User -> cloudflare -> server
Where cloudflare expects a valid certificate on the server (ouch)
I currently don’t have access to the cloudflare configuration

Okay so I do have root access on the server and here is my caddyfile {
gzip {
ext *
level 9
tls web/ web/
proxy / localhost:10002
} {
tls web/ web/
proxy / localhost:1002

I’m trying to use certbot to fetch certificates for this (caddy can’t do it automatically when this cloudflare bs is in place)

When I use the webroot option I get this


Is there any way I can change caddy’s behaviour to not return 404 and accept every request?

(Anuprita Duggal) #2

Caddy version is the latest release on github

(Anuprita Duggal) #3

The :80 :443 combination on botstack is weird but that’s the way cloudflare wants it otherwise it drops the connection

(Anuprita Duggal) #4

Basically I’m trying to get certbot to issue a single certificate for all of these domains so that it becomes easier to manage

The certbot command I used was

sudo certbot certonly --config-dir . --work-dir . --logs-dir . --rsa-key-size 4096

(Anuprita Duggal) #5

Going to mark this issue as resolved
Will share details later

(Anuprita Duggal) #6

Ok so the issue was that caddy wasn’t redirecting http requests to https
adding {
redir 308 {
if {>X-Forwarded-Proto} is http
/ https://{host}{uri}
} Instantly fixed the issue