nixos/nginx: add reuseport option

This commit is contained in:
Izorkin 2022-03-07 15:44:24 +03:00 committed by Yuka
parent 660a36f173
commit c508da303b
2 changed files with 14 additions and 3 deletions

View File

@ -259,6 +259,7 @@ let
# UDP listener for **QUIC+HTTP/3 # UDP listener for **QUIC+HTTP/3
listen ${addr}:${toString port} http3 " listen ${addr}:${toString port} http3 "
+ optionalString vhost.default "default_server " + optionalString vhost.default "default_server "
+ optionalString vhost.reuseport "reuseport "
+ ";" else "") + ";" else "")
+ " + "
@ -266,6 +267,7 @@ let
+ optionalString (ssl && vhost.http2) "http2 " + optionalString (ssl && vhost.http2) "http2 "
+ optionalString ssl "ssl " + optionalString ssl "ssl "
+ optionalString vhost.default "default_server " + optionalString vhost.default "default_server "
+ optionalString vhost.reuseport "reuseport "
+ optionalString (extraParameters != []) (concatStringsSep " " extraParameters) + optionalString (extraParameters != []) (concatStringsSep " " extraParameters)
+ ";"; + ";";

View File

@ -20,7 +20,7 @@ with lib;
serverAliases = mkOption { serverAliases = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
example = ["www.example.org" "example.org"]; example = [ "www.example.org" "example.org" ];
description = '' description = ''
Additional names of virtual hosts served by this virtual host configuration. Additional names of virtual hosts served by this virtual host configuration.
''; '';
@ -31,11 +31,11 @@ with lib;
addr = mkOption { type = str; description = "IP address."; }; addr = mkOption { type = str; description = "IP address."; };
port = mkOption { type = int; description = "Port number."; default = 80; }; port = mkOption { type = int; description = "Port number."; default = 80; };
ssl = mkOption { type = bool; description = "Enable SSL."; default = false; }; ssl = mkOption { type = bool; description = "Enable SSL."; default = false; };
extraParameters = mkOption { type = listOf str; description = "Extra parameters of this listen directive."; default = []; example = [ "reuseport" "deferred" ]; }; extraParameters = mkOption { type = listOf str; description = "Extra parameters of this listen directive."; default = []; example = [ "backlog=1024" "deferred" ]; };
}; }); }; });
default = []; default = [];
example = [ example = [
{ addr = "195.154.1.1"; port = 443; ssl = true;} { addr = "195.154.1.1"; port = 443; ssl = true; }
{ addr = "192.154.1.1"; port = 80; } { addr = "192.154.1.1"; port = 80; }
]; ];
description = '' description = ''
@ -207,6 +207,15 @@ with lib;
''; '';
}; };
reuseport = mkOption {
type = types.bool;
default = false;
description = ''
Create an individual listening socket .
It is required to specify only once on one of the hosts.
'';
};
root = mkOption { root = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;