aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/nixos/modules/services/web-servers
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/nixpkgs/nixos/modules/services/web-servers')
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix4
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/caddy.nix14
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix25
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix28
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix7
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/services/web-servers/traefik.nix4
6 files changed, 59 insertions, 23 deletions
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
index 6ffda3d63614..dc78728d6636 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -750,8 +750,8 @@ in
# Get rid of old semaphores. These tend to accumulate across
# server restarts, eventually preventing it from restarting
# successfully.
- for i in $(${pkgs.utillinux}/bin/ipcs -s | grep ' ${cfg.user} ' | cut -f2 -d ' '); do
- ${pkgs.utillinux}/bin/ipcrm -s $i
+ for i in $(${pkgs.util-linux}/bin/ipcs -s | grep ' ${cfg.user} ' | cut -f2 -d ' '); do
+ ${pkgs.util-linux}/bin/ipcrm -s $i
done
'';
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/caddy.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/caddy.nix
index 72bf9a9a1f44..297b73273392 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/caddy.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/caddy.nix
@@ -24,6 +24,10 @@ let
${pkgs.jq}/bin/jq -s '.[0] * .[1]' ${adaptedConfig} ${tlsJSON} > $out
'';
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "caddy" "agree" ] "this option is no longer necessary for Caddy 2")
+ ];
+
options.services.caddy = {
enable = mkEnableOption "Caddy web server";
@@ -66,12 +70,6 @@ in {
description = "Email address (for Let's Encrypt certificate)";
};
- agree = mkOption {
- default = false;
- type = types.bool;
- description = "Agree to Let's Encrypt Subscriber Agreement";
- };
-
dataDir = mkOption {
default = "/var/lib/caddy";
type = types.path;
@@ -103,6 +101,8 @@ in {
after = [ "network-online.target" ];
wants = [ "network-online.target" ]; # systemd-networkd-wait-online.service
wantedBy = [ "multi-user.target" ];
+ startLimitIntervalSec = 14400;
+ startLimitBurst = 10;
serviceConfig = {
ExecStart = "${cfg.package}/bin/caddy run --config ${configJSON}";
ExecReload = "${cfg.package}/bin/caddy reload --config ${configJSON}";
@@ -110,8 +110,6 @@ in {
User = "caddy";
Group = "caddy";
Restart = "on-abnormal";
- StartLimitIntervalSec = 14400;
- StartLimitBurst = 10;
AmbientCapabilities = "cap_net_bind_service";
CapabilityBoundingSet = "cap_net_bind_service";
NoNewPrivileges = true;
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
index 39bcb14e5afe..e9630d379f36 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
@@ -34,7 +34,6 @@ let
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
- proxy_set_header Accept-Encoding "";
'';
upstreamConfig = toString (flip mapAttrsToList cfg.upstreams (name: upstream: ''
@@ -87,7 +86,7 @@ let
''}
ssl_protocols ${cfg.sslProtocols};
- ssl_ciphers ${cfg.sslCiphers};
+ ${optionalString (cfg.sslCiphers != null) "ssl_ciphers ${cfg.sslCiphers};"}
${optionalString (cfg.sslDhparam != null) "ssl_dhparam ${cfg.sslDhparam};"}
${optionalString (cfg.recommendedTlsSettings) ''
@@ -262,10 +261,7 @@ let
ssl_trusted_certificate ${vhost.sslTrustedCertificate};
''}
- ${optionalString (vhost.basicAuthFile != null || vhost.basicAuth != {}) ''
- auth_basic secured;
- auth_basic_user_file ${if vhost.basicAuthFile != null then vhost.basicAuthFile else mkHtpasswd vhostName vhost.basicAuth};
- ''}
+ ${mkBasicAuth vhostName vhost}
${mkLocations vhost.locations}
@@ -294,9 +290,19 @@ let
${optionalString (config.return != null) "return ${config.return};"}
${config.extraConfig}
${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"}
+ ${mkBasicAuth "sublocation" config}
}
'') (sortProperties (mapAttrsToList (k: v: v // { location = k; }) locations)));
- mkHtpasswd = vhostName: authDef: pkgs.writeText "${vhostName}.htpasswd" (
+
+ mkBasicAuth = name: zone: optionalString (zone.basicAuthFile != null || zone.basicAuth != {}) (let
+ auth_file = if zone.basicAuthFile != null
+ then zone.basicAuthFile
+ else mkHtpasswd name zone.basicAuth;
+ in ''
+ auth_basic secured;
+ auth_basic_user_file ${auth_file};
+ '');
+ mkHtpasswd = name: authDef: pkgs.writeText "${name}.htpasswd" (
concatStringsSep "\n" (mapAttrsToList (user: password: ''
${user}:{PLAIN}${password}
'') authDef)
@@ -488,7 +494,7 @@ in
};
sslCiphers = mkOption {
- type = types.str;
+ type = types.nullOr types.str;
# Keep in sync with https://ssl-config.mozilla.org/#server=nginx&config=intermediate
default = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
description = "Ciphers to choose from when negotiating TLS handshakes.";
@@ -694,6 +700,8 @@ in
${cfg.preStart}
${execCommand} -t
'';
+
+ startLimitIntervalSec = 60;
serviceConfig = {
ExecStart = execCommand;
ExecReload = [
@@ -702,7 +710,6 @@ in
];
Restart = "always";
RestartSec = "10s";
- StartLimitInterval = "1min";
# User and group
User = cfg.user;
Group = cfg.group;
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
index 3d9e391ecf20..f2fc07255725 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
@@ -9,6 +9,34 @@ with lib;
{
options = {
+ basicAuth = mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ example = literalExample ''
+ {
+ user = "password";
+ };
+ '';
+ description = ''
+ Basic Auth protection for a vhost.
+
+ WARNING: This is implemented to store the password in plain text in the
+ Nix store.
+ '';
+ };
+
+ basicAuthFile = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ description = ''
+ Basic Auth password file for a vhost.
+ Can be created via: <command>htpasswd -c &lt;filename&gt; &lt;username&gt;</command>.
+
+ WARNING: The generate file contains the users' passwords in a
+ non-cryptographically-securely hashed way.
+ '';
+ };
+
proxyPass = mkOption {
type = types.nullOr types.str;
default = null;
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
index 455854e2a965..cf211ea9a71b 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
@@ -198,7 +198,7 @@ with lib;
Basic Auth protection for a vhost.
WARNING: This is implemented to store the password in plain text in the
- nix store.
+ Nix store.
'';
};
@@ -207,7 +207,10 @@ with lib;
default = null;
description = ''
Basic Auth password file for a vhost.
- Can be created via: <command>htpasswd -c &lt;filename&gt; &lt;username&gt;</command>
+ Can be created via: <command>htpasswd -c &lt;filename&gt; &lt;username&gt;</command>.
+
+ WARNING: The generate file contains the users' passwords in a
+ non-cryptographically-securely hashed way.
'';
};
diff --git a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/traefik.nix b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/traefik.nix
index 4ab7307c3b67..3d29199dd454 100644
--- a/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/traefik.nix
+++ b/infra/libkookie/nixpkgs/nixos/modules/services/web-servers/traefik.nix
@@ -136,6 +136,8 @@ in {
description = "Traefik web server";
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
+ startLimitIntervalSec = 86400;
+ startLimitBurst = 5;
serviceConfig = {
ExecStart =
"${cfg.package}/bin/traefik --configfile=${staticConfigFile}";
@@ -143,8 +145,6 @@ in {
User = "traefik";
Group = cfg.group;
Restart = "on-failure";
- StartLimitInterval = 86400;
- StartLimitBurst = 5;
AmbientCapabilities = "cap_net_bind_service";
CapabilityBoundingSet = "cap_net_bind_service";
NoNewPrivileges = true;