nginx: allow null upstream option

This commit is contained in:
ibizaman 2025-12-29 22:51:23 +01:00 committed by Pierre Penninckx
parent f48048a4f6
commit edce2b26ad

View file

@ -31,8 +31,9 @@ let
}; };
upstream = lib.mkOption { upstream = lib.mkOption {
type = lib.types.str; type = lib.types.nullOr lib.types.str;
description = "Upstream url to be protected."; description = "Upstream url to be protected.";
default = null;
example = "http://127.0.0.1:1234"; example = "http://127.0.0.1:1234";
}; };
@ -157,7 +158,8 @@ in
sslCertificateKey = lib.mkIf (!(isNull c.ssl)) c.ssl.paths.key; sslCertificateKey = lib.mkIf (!(isNull c.ssl)) c.ssl.paths.key;
# Taken from https://github.com/authelia/authelia/issues/178 # Taken from https://github.com/authelia/authelia/issues/178
locations."/".extraConfig = '' locations."/".extraConfig =
lib.optionalString (c.upstream != null) ''
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN"; add_header X-Frame-Options "SAMEORIGIN";
@ -201,6 +203,7 @@ in
error_page 403 = ${c.authEndpoint}/error/403; error_page 403 = ${c.authEndpoint}/error/403;
''; '';
# Virtual endpoint created by nginx to forward auth requests. # Virtual endpoint created by nginx to forward auth requests.
locations."/authelia".extraConfig = lib.mkIf (!(isNull c.authEndpoint)) '' locations."/authelia".extraConfig = lib.mkIf (!(isNull c.authEndpoint)) ''
internal; internal;