Skip to content

Commit 506a90f

Browse files
committed
develop: cockpit: nginx virtual host extra config
1 parent 6f21747 commit 506a90f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

modules/nixos/cockpit/default.nix

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ let
1313
mkDefault
1414
mkIf
1515
mkOption
16-
optional
1716
types
1817
;
1918
in
@@ -37,6 +36,7 @@ in
3736
settings = {
3837
WebService = {
3938
AllowUnencrypted = mkDefault true;
39+
ProtocolHeader = mkDefault "X-Forwarded-Proto";
4040
};
4141
Log = {
4242
Fatal = mkDefault "criticals warnings";
@@ -45,8 +45,9 @@ in
4545
allowed-origins = [
4646
"http://localhost:${toString cfg.port}"
4747
"http://${fqdn}"
48-
]
49-
++ optional (cfg.forceSSL) "https://${fqdn}";
48+
"https://${fqdn}"
49+
"wss://${fqdn}"
50+
];
5051
};
5152

5253
# https://github.com/NixOS/nixpkgs/issues/179676
@@ -56,7 +57,23 @@ in
5657
"${fqdn}" = {
5758
enableACME = cfg.forceSSL;
5859
forceSSL = cfg.forceSSL;
59-
locations."/".proxyPass = mkDefault "http://localhost:${toString cfg.port}";
60+
locations."/" = {
61+
proxyPass = mkDefault "http://localhost:${toString cfg.port}";
62+
extraConfig = ''
63+
proxy_set_header Host $host;
64+
proxy_set_header X-Forwarded-Proto $scheme;
65+
66+
# Required for web sockets to function
67+
proxy_http_version 1.1;
68+
proxy_buffering off;
69+
proxy_set_header Upgrade $http_upgrade;
70+
proxy_set_header Connection "upgrade";
71+
72+
# Pass ETag header from Cockpit to clients.
73+
# See: https://github.com/cockpit-project/cockpit/issues/5239
74+
gzip off;
75+
'';
76+
};
6077
};
6178
};
6279
};

0 commit comments

Comments
 (0)