Skip to content

Commit 3aa5a47

Browse files
nginx: assert that HSTS header are set correctly
1 parent d1bb9ac commit 3aa5a47

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/nginx.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ in
8888
];
8989

9090
config = lib.mkIf cfg.enable {
91+
assertions = lib.mkIf cfg.setHSTSHeader (lib.attrValues (lib.mapAttrs (host: hostConfig: {
92+
assertion = hostConfig.root == null;
93+
message = let
94+
name = ''services.nginx.virtualHosts."${host}"'';
95+
in "Use ${name}.locations./.root instead of ${name}.root to properly apply .locations.*.extraConfig set by services.nginx.setHSTSHeader";
96+
}) cfg.virtualHosts));
97+
9198
boot.kernel.sysctl = lib.mkIf cfg.tcpFastOpen {
9299
# enable tcp fastopen for outgoing and incoming connections
93100
"net.ipv4.tcp_fastopen" = 3;

0 commit comments

Comments
 (0)