Publish a security.txt file on nginx
Why it matters
A security.txt file tells researchers who to contact when they find a security problem on your site, so a report reaches you instead of being posted publicly or lost. It is a small plain text file defined in RFC 9116.
The fix
- Create the file at /var/www/security/.well-known/security.txt with the content shown in the generic tab (any directory works; adjust the root below).
- Add the location block inside the server block for example.com. An exact-match location wins over a regex rule that denies dotfiles, so it also works if you block paths starting with a dot.
- Run nginx -t, then reload nginx. Browse to https://example.com/.well-known/security.txt and check the content type is text/plain with charset=utf-8.
/ etc/ nginx/ conf.d/ example.com.conf
location = /.well-known/security.txt { root /var/www/security; default_type text/plain; charset utf-8; }
The examples use example.com. Replace it with your own domain.
Related
- Reported by the security.txt check
- Serve security.txt from /.well-known/
- Serve security.txt over https
- Serve security.txt as text/plain with utf-8
- Add a Contact line to security.txt
- Fix the Contact value in security.txt
- Add an Expires line to security.txt
- Use an RFC 3339 date in the Expires line
- Renew the expired security.txt
- Renew security.txt before it expires
- Shorten the security.txt Expires date
- Fix repeated or insecure fields in security.txt
- Make the Canonical line match where the file is served
Scan your domain to see whether this applies to you.