fix(#1263): repeat security headers in locations with their own add_header
This commit is contained in:
parent
681a86bce9
commit
911dc5227b
1 changed files with 9 additions and 9 deletions
|
|
@ -418,11 +418,7 @@ in
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
assertion =
|
assertion = !cfg.hsts.enable || cfg.selfSignedTls || cfg.tls.certDir != null || cfg.tls.acme.enable;
|
||||||
!cfg.hsts.enable
|
|
||||||
|| cfg.selfSignedTls
|
|
||||||
|| cfg.tls.certDir != null
|
|
||||||
|| cfg.tls.acme.enable;
|
|
||||||
message = ''
|
message = ''
|
||||||
services.hyperhive.gateway.hsts.enable = true requires TLS to be
|
services.hyperhive.gateway.hsts.enable = true requires TLS to be
|
||||||
configured (selfSignedTls, tls.certDir, or tls.acme.enable). HSTS
|
configured (selfSignedTls, tls.certDir, or tls.acme.enable). HSTS
|
||||||
|
|
@ -549,10 +545,12 @@ in
|
||||||
|
|
||||||
# Security headers added at the server scope on every vhost.
|
# Security headers added at the server scope on every vhost.
|
||||||
# nginx's add_header inheritance rule: a location that defines its
|
# nginx's add_header inheritance rule: a location that defines its
|
||||||
# own add_header does NOT inherit the server-level ones, so API
|
# own add_header does NOT inherit the server-level ones. Any
|
||||||
# locations with CORS headers (e.g. /.well-known/matrix/client,
|
# location with its own add_header (e.g. CORS on /.well-known or
|
||||||
# /_matrix/) are unaffected. HTML-serving and proxy locations that
|
# /_matrix/) must repeat the security headers explicitly — see those
|
||||||
# carry no add_header of their own pick these up automatically.
|
# locations below. HTML-serving and proxy locations that carry no
|
||||||
|
# add_header of their own pick these up from the server scope
|
||||||
|
# automatically.
|
||||||
hstsDirectives = lib.concatStringsSep "; " (
|
hstsDirectives = lib.concatStringsSep "; " (
|
||||||
[ "max-age=${toString cfg.hsts.maxAge}" ]
|
[ "max-age=${toString cfg.hsts.maxAge}" ]
|
||||||
++ lib.optional cfg.hsts.includeSubDomains "includeSubDomains"
|
++ lib.optional cfg.hsts.includeSubDomains "includeSubDomains"
|
||||||
|
|
@ -726,6 +724,7 @@ in
|
||||||
"= /.well-known/matrix/client" = {
|
"= /.well-known/matrix/client" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
default_type application/json;
|
default_type application/json;
|
||||||
|
${securityHeaders}
|
||||||
add_header Access-Control-Allow-Origin *;
|
add_header Access-Control-Allow-Origin *;
|
||||||
return 200 '{"m.homeserver":{"base_url":"${clientBaseUrl}"}}';
|
return 200 '{"m.homeserver":{"base_url":"${clientBaseUrl}"}}';
|
||||||
'';
|
'';
|
||||||
|
|
@ -906,6 +905,7 @@ in
|
||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
proxy_read_timeout 1h;
|
proxy_read_timeout 1h;
|
||||||
proxy_send_timeout 1h;
|
proxy_send_timeout 1h;
|
||||||
|
${securityHeaders}
|
||||||
add_header Access-Control-Allow-Origin *;
|
add_header Access-Control-Allow-Origin *;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue