nixos/nginx: update quic configuration

Izorkin 77d6fd36 9f2a1d98

Changed files
+59 -11
nixos
doc
manual
release-notes
modules
services
web-servers
+2
nixos/doc/manual/release-notes/rl-2305.section.md
···
- [services.xserver.videoDrivers](options.html#opt-services.xserver.videoDrivers) now defaults to the `modesetting` driver over device-specific ones. The `radeon`, `amdgpu` and `nouveau` drivers are still available, but effectively unmaintained and not recommended for use.
- conntrack helper autodetection has been removed from kernels 6.0 and up upstream, and an assertion was added to ensure things don't silently stop working. Migrate your configuration to assign helpers explicitly or use an older LTS kernel branch as a temporary workaround.
- The `services.pipewire.config` options have been removed, as they have basically never worked correctly. All behavior defined by the default configuration can be overridden with drop-in files as necessary - see [below](#sec-release-23.05-migration-pipewire) for details.
···
- [services.xserver.videoDrivers](options.html#opt-services.xserver.videoDrivers) now defaults to the `modesetting` driver over device-specific ones. The `radeon`, `amdgpu` and `nouveau` drivers are still available, but effectively unmaintained and not recommended for use.
+
- To enable the HTTP3 (QUIC) protocol for a nginx virtual host, set the `quic` attribute on it to true, e.g. `services.nginx.virtualHosts.<name>.quic = true;`.
+
- conntrack helper autodetection has been removed from kernels 6.0 and up upstream, and an assertion was added to ensure things don't silently stop working. Migrate your configuration to assign helpers explicitly or use an older LTS kernel branch as a temporary workaround.
- The `services.pipewire.config` options have been removed, as they have basically never worked correctly. All behavior defined by the default configuration can be overridden with drop-in files as necessary - see [below](#sec-release-23.05-migration-pipewire) for details.
+22 -6
nixos/modules/services/web-servers/nginx/default.nix
···
else defaultListen;
listenString = { addr, port, ssl, extraParameters ? [], ... }:
-
(if ssl && vhost.http3 then "
-
# UDP listener for **QUIC+HTTP/3
-
listen ${addr}:${toString port} http3 "
+ optionalString vhost.default "default_server "
+ optionalString vhost.reuseport "reuseport "
-
+ optionalString (extraParameters != []) (concatStringsSep " " extraParameters)
+ ";" else "")
+ "
···
server {
${concatMapStringsSep "\n" listenString hostListen}
server_name ${vhost.serverName} ${concatStringsSep " " vhost.serverAliases};
${acmeLocation}
${optionalString (vhost.root != null) "root ${vhost.root};"}
${optionalString (vhost.globalRedirect != null) ''
···
ssl_conf_command Options KTLS;
''}
-
${optionalString (hasSSL && vhost.http3) ''
# Advertise that HTTP/3 is available
-
add_header Alt-Svc 'h3=":443"; ma=86400' always;
''}
${mkBasicAuth vhostName vhost}
···
message = ''
Options services.nginx.service.virtualHosts.<name>.enableACME and
services.nginx.virtualHosts.<name>.useACMEHost are mutually exclusive.
'';
}
] ++ map (name: mkCertOwnershipAssertion {
···
else defaultListen;
listenString = { addr, port, ssl, extraParameters ? [], ... }:
+
# UDP listener for QUIC transport protocol.
+
(if ssl && vhost.quic then "
+
listen ${addr}:${toString port} quic "
+ optionalString vhost.default "default_server "
+ optionalString vhost.reuseport "reuseport "
+
+ optionalString (extraParameters != []) (concatStringsSep " " (
+
let inCompatibleParameters = [ "ssl" "proxy_protocol" "http2" ];
+
isCompatibleParameter = param: !(any (p: p == param) inCompatibleParameters);
+
in filter isCompatibleParameter extraParameters))
+ ";" else "")
+ "
···
server {
${concatMapStringsSep "\n" listenString hostListen}
server_name ${vhost.serverName} ${concatStringsSep " " vhost.serverAliases};
+
${optionalString (hasSSL && vhost.quic) ''
+
http3 ${if vhost.http3 then "on" else "off"};
+
http3_hq ${if vhost.http3_hq then "on" else "off"};
+
''}
${acmeLocation}
${optionalString (vhost.root != null) "root ${vhost.root};"}
${optionalString (vhost.globalRedirect != null) ''
···
ssl_conf_command Options KTLS;
''}
+
${optionalString (hasSSL && vhost.quic && vhost.http3)
# Advertise that HTTP/3 is available
+
''
+
add_header Alt-Svc 'h3=":$server_port"; ma=86400';
''}
${mkBasicAuth vhostName vhost}
···
message = ''
Options services.nginx.service.virtualHosts.<name>.enableACME and
services.nginx.virtualHosts.<name>.useACMEHost are mutually exclusive.
+
'';
+
}
+
+
{
+
assertion = cfg.package.pname != "nginxQuic" -> all (host: !host.quic) (attrValues virtualHosts);
+
message = ''
+
services.nginx.service.virtualHosts.<name>.quic requires using nginxQuic package,
+
which can be achieved by setting `services.nginx.package = pkgs.nginxQuic;`.
'';
}
] ++ map (name: mkCertOwnershipAssertion {
+35 -5
nixos/modules/services/web-servers/nginx/vhost-options.nix
···
type = types.bool;
default = true;
description = lib.mdDoc ''
-
Whether to enable HTTP 2.
Note that (as of writing) due to nginx's implementation, to disable
-
HTTP 2 you have to disable it on all vhosts that use a given
IP address / port.
-
If there is one server block configured to enable http2,then it is
enabled for all server blocks on this IP.
See https://stackoverflow.com/a/39466948/263061.
'';
···
http3 = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
-
Whether to enable HTTP 3.
This requires using `pkgs.nginxQuic` package
which can be achieved by setting `services.nginx.package = pkgs.nginxQuic;`.
-
Note that HTTP 3 support is experimental and
*not* yet recommended for production.
Read more at https://quic.nginx.org/
'';
···
type = types.bool;
default = true;
description = lib.mdDoc ''
+
Whether to enable the HTTP/2 protocol.
Note that (as of writing) due to nginx's implementation, to disable
+
HTTP/2 you have to disable it on all vhosts that use a given
IP address / port.
+
If there is one server block configured to enable http2, then it is
enabled for all server blocks on this IP.
See https://stackoverflow.com/a/39466948/263061.
'';
···
http3 = mkOption {
type = types.bool;
+
default = true;
+
description = lib.mdDoc ''
+
Whether to enable the HTTP/3 protocol.
+
This requires using `pkgs.nginxQuic` package
+
which can be achieved by setting `services.nginx.package = pkgs.nginxQuic;`
+
and activate the QUIC transport protocol
+
`services.nginx.virtualHosts.<name>.quic = true;`.
+
Note that HTTP/3 support is experimental and
+
*not* yet recommended for production.
+
Read more at https://quic.nginx.org/
+
'';
+
};
+
+
http3_hq = mkOption {
+
type = types.bool;
default = false;
description = lib.mdDoc ''
+
Whether to enable the HTTP/0.9 protocol negotiation used in QUIC interoperability tests.
+
This requires using `pkgs.nginxQuic` package
+
which can be achieved by setting `services.nginx.package = pkgs.nginxQuic;`
+
and activate the QUIC transport protocol
+
`services.nginx.virtualHosts.<name>.quic = true;`.
+
Note that special application protocol support is experimental and
+
*not* yet recommended for production.
+
Read more at https://quic.nginx.org/
+
'';
+
};
+
+
quic = mkOption {
+
type = types.bool;
+
default = false;
+
description = lib.mdDoc ''
+
Whether to enable the QUIC transport protocol.
This requires using `pkgs.nginxQuic` package
which can be achieved by setting `services.nginx.package = pkgs.nginxQuic;`.
+
Note that QUIC support is experimental and
*not* yet recommended for production.
Read more at https://quic.nginx.org/
'';