services.nginx: allow startup with ipv6 disabled (#21360)
currently services.nginx does not start up if `networking.enableIPv6 = false` the commit changes the nginx behavior to handle this case accordingly. The commit resolves #21308
This commit is contained in:
parent
9f6bd82364
commit
d8478c7912
@ -10,6 +10,7 @@ let
|
|||||||
sslCertificateKey = "/var/lib/acme/${vhostName}/key.pem";
|
sslCertificateKey = "/var/lib/acme/${vhostName}/key.pem";
|
||||||
})
|
})
|
||||||
) cfg.virtualHosts;
|
) cfg.virtualHosts;
|
||||||
|
enableIPv6 = config.networking.enableIPv6;
|
||||||
|
|
||||||
configFile = pkgs.writeText "nginx.conf" ''
|
configFile = pkgs.writeText "nginx.conf" ''
|
||||||
user ${cfg.user} ${cfg.group};
|
user ${cfg.user} ${cfg.group};
|
||||||
@ -84,7 +85,7 @@ let
|
|||||||
${optionalString cfg.statusPage ''
|
${optionalString cfg.statusPage ''
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
${optionalString enableIPv6 "listen [::]:80;" }
|
||||||
|
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ let
|
|||||||
stub_status on;
|
stub_status on;
|
||||||
access_log off;
|
access_log off;
|
||||||
allow 127.0.0.1;
|
allow 127.0.0.1;
|
||||||
allow ::1;
|
${optionalString enableIPv6 "allow ::1;"}
|
||||||
deny all;
|
deny all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,7 +134,9 @@ let
|
|||||||
${optionalString vhost.forceSSL ''
|
${optionalString vhost.forceSSL ''
|
||||||
server {
|
server {
|
||||||
listen 80 ${optionalString vhost.default "default"};
|
listen 80 ${optionalString vhost.default "default"};
|
||||||
listen [::]:80 ${optionalString vhost.default "default"};
|
${optionalString enableIPv6
|
||||||
|
''listen [::]:80 ${optionalString vhost.default "default"};''
|
||||||
|
}
|
||||||
|
|
||||||
server_name ${serverName} ${concatStringsSep " " vhost.serverAliases};
|
server_name ${serverName} ${concatStringsSep " " vhost.serverAliases};
|
||||||
${acmeLocation}
|
${acmeLocation}
|
||||||
@ -145,7 +148,7 @@ let
|
|||||||
|
|
||||||
server {
|
server {
|
||||||
listen ${listenString};
|
listen ${listenString};
|
||||||
listen [::]:${listenString};
|
${optionalString enableIPv6 "listen [::]:${listenString};"}
|
||||||
|
|
||||||
server_name ${serverName} ${concatStringsSep " " vhost.serverAliases};
|
server_name ${serverName} ${concatStringsSep " " vhost.serverAliases};
|
||||||
${acmeLocation}
|
${acmeLocation}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user