Caddy file review

1. The problem I’m having:

I’d like a general review of my Caddy file – any comments on structure, unnecessary stuff, etc.

I also have these two questions:

  1. Is there a way to suppress output to the shell, at least after initial config/startup?
  2. Is there a better way to apply global header params than using a function in each subdomain?

2. Error messages and/or full log output:

n/a

3. Caddy version:

2.6.4

4. How I installed and ran Caddy:

a. System environment:

Win10 Pro x64

b. Command:

caddy run

d. My complete Caddy config:

{
	email myemail@email.net
	default_sni justinsdomain.com
	servers :8443 {
		protocols h2 h1
	}
	#log stdout
	log caddy-log {
		output file caddy.log	
	}
}
(headers) {
	header {
		Strict-Transport-Security "max-age=31536000; includeSubDomains;"
    		X-Xss-Protection "1; mode=block"
    		X-Content-Type-Options "nosniff"
    		X-Frame-Options "SAMEORIGIN"
    		Content-Security-Policy "upgrade-insecure-requests"
    		Referrer-Policy "strict-origin-when-cross-origin"
    		Cache-Control "public, max-age=15, must-revalidate"
	}
}
(logging) {
	log {
		output file "{args.0}.log"
	}
}
#file server 1
serv1.justinsdomain.com:8443 {
	log {
		output file caddy-Serv1.log
	}
	reverse_proxy :8080
	encode zstd gzip
	import headers
}
#file server 2
serv2.justinsdomain.com:8443 {
	import logging Serv2
	reverse_proxy :8081
	encode zstd gzip
	import headers
}

Looks fine to me.

Yeah, remove the name for your logger so that it’s the default logger.

i.e. log caddy-log { remove caddy-log from there.

Those aren’t functions, they’re snippets. And no, that’s the way to do it. Each site must be explicitly configured. We have no plans to add implicit configuration, it adds way too much complexity.

1 Like

Appreciate that info!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.