I’m trying to set up Caddy for my PaaS app where users will have their blogs hosted either under a subdomain myblog.mydomain.com or directly via a custom domain name myblog.com.
My current Caddyfile has the following configuration:
I’m not sure I fully understand you but I’ll try to see if I can help.
Caddy requires a fully configured block for each server. So if you wish to have :443 and *.example.com that is fine and you can have them in any order but you must provide all config in both blocks so
Is what is required. IF you are still haveing problems please post your full unedited caddyfile and start with the log directive caddy -log stdout and post any logs you get.
Thanks for the response. I didn’t leave the subdomain block empty in my actual Caddyfile, I didn’t paste it here because it was the same as my other block.
Except, it has the extra directive:
tls {
dns cloudflare
wildcard
}
I’ll try applying this config again and see what happens. Will update the thread accordingly.
You don’t need to add the wildcard subdirective if you’ve already got a wildcard in the site label. This subdirective is intended to be used when you have a fully qualified domain name that you want Caddy to treat as though it were a wildcard.
Adding a wildcard subdirective to a site label with a wildcard should, if I recall correctly, produce an error on startup, hence Caddy not serving either of your sites.
There’s still some ambiguity here - you say you added the extra directive, did that replace the tls directive of the original, or are you running one tls block with ask endpoint and one tls block with dns cloudflare and wildcard?
Just a reminder - even if you think it’s superfluous, posting your entire, unedited Caddyfile, and remembering to copy and paste any Caddy output such as process logs, will get you much better help faster.
Yes, you’re right. Cloudflare doesn’t show up in the list:
Server types:
http
Caddyfile loaders:
short
flag
default
Other plugins:
http.basicauth
http.bind
http.browse
http.errors
http.expvar
http.ext
http.fastcgi
http.gzip
http.header
http.index
http.internal
http.limits
http.log
http.markdown
http.mime
http.pprof
http.proxy
http.push
http.redir
http.request_id
http.rewrite
http.root
http.status
http.templates
http.timeouts
http.websocket
on
tls
tls.cluster.file
I’ve added the plugin in the imports section:
lumberjack "gopkg.in/natefinch/lumberjack.v2"
_ "github.com/mholt/caddy/caddyhttp" // plug in the HTTP server type
// This is where other plugins get plugged in (imported)
_ "github.com/caddyserver/dnsproviders/cloudflare"
Huh, that’s odd. I’m like 98% sure that wildcard sites, with ambiguous scheme and Automatic HTTPS enabled, should set up a HTTP redirect listener as normal.
Easiest way to workaround that issue would be to further split *.example.com into two sites: