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

botstack.host:443 help.botstack.host vmd16339.contabo.host srv1.botstack.host {
gzip {
ext *
level 9
}
tls web/ssl.help.botstack.host.crt web/ssl.help.botstack.host.key
proxy / localhost:10002
bind 0.0.0.0
}
botstack.host:80 {
tls web/ssl.botstack.host.crt web/ssl.botstack.host.key
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

IMPORTANT NOTES:

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
botstack.host:80 vmd16339.contabo.host:80 srv1.botstack.host:80 help.botstack.host:80 {
redir 308 {
if {>X-Forwarded-Proto} is http
/ https://{host}{uri}
} Instantly fixed the issue