Security Headers
SWS provides several security headers support.
The feature is enabled by default when SWS is built with the TLS feature, as all release binaries are, and can be controlled by the boolean --security-headers option or the equivalent SERVER_SECURITY_HEADERS env.
Customize HTTP headers
If you want to customize HTTP headers on demand then have a look at the Custom HTTP Headers section.
Headers included
The following headers are included on every response.
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Content-Security-Policy: frame-ancestors 'self'
Referrer-Policy: strict-origin-when-cross-originWhen SWS serves TLS (--tls), the responses also include:
Strict-Transport-Security: max-age=63072000; includeSubDomainsHSTS
Strict-Transport-Security (HSTS) tells browsers to use only HTTPS for the host and its subdomains for two years. SWS doesn't send it over plain HTTP, since RFC 6797 forbids it there.
If SWS serves plain HTTP behind a proxy that terminates TLS, add HSTS at the proxy, or with a custom header rule.
The default value doesn't include preload, since adding a domain to the browser preload lists is up to its owner. To opt in, set the header with a custom header rule:
[advanced]
[[advanced.headers]]
source = "**"
headers.Strict-Transport-Security = "max-age=63072000; includeSubDomains; preload"Custom header rules apply to every response
Unlike the built-in header, a custom header rule also applies over plain HTTP. Only add HSTS this way when every client reaches SWS over HTTPS.