webzod
account

Serve security.txt as text/plain with utf-8 on Caddy

hygiene.security_txt.wrong_content_type · effort: minutes

Why it matters

RFC 9116 requires the file to be sent as text/plain in utf-8. Tools may reject it if the server labels it as html, binary or another charset.

The fix

  1. Serve the file with file_server from a real file named security.txt, which Caddy sends as text/plain with the utf-8 charset. If you use respond to serve the text instead, set the header explicitly.
  2. Reload Caddy and check the Content-Type header again.
Caddyfile
example.com {
	handle /.well-known/security.txt {
		header Content-Type "text/plain; charset=utf-8"
		root * /var/www/security
		file_server
	}
}

The examples use example.com. Replace it with your own domain.

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.