nginx: add phpForwardAuth

This commit is contained in:
ibizaman 2025-12-29 22:51:48 +01:00
parent a4af5f56b6
commit 303dff30be
3 changed files with 16 additions and 0 deletions

View file

@ -1163,6 +1163,9 @@
"blocks-nginx-options-shb.nginx.vhosts._.extraConfig": [
"blocks-nginx.html#blocks-nginx-options-shb.nginx.vhosts._.extraConfig"
],
"blocks-nginx-options-shb.nginx.vhosts._.phpForwardAuth": [
"blocks-nginx.html#blocks-nginx-options-shb.nginx.vhosts._.phpForwardAuth"
],
"blocks-nginx-options-shb.nginx.vhosts._.ssl": [
"blocks-nginx.html#blocks-nginx-options-shb.nginx.vhosts._.ssl"
],

View file

@ -79,6 +79,12 @@ let
'';
};
phpForwardAuth = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Authelia rule configuration";
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
@ -203,6 +209,10 @@ in
error_page 403 = ${c.authEndpoint}/error/403;
'';
locations."~ \\.php$".extraConfig = lib.mkIf (c.phpForwardAuth) ''
fastcgi_param HTTP_X_FORWARDED_USER $user;
fastcgi_param HTTP_X_FORWARDED_GROUPS $groups;
'';
# Virtual endpoint created by nginx to forward auth requests.
locations."/authelia".extraConfig = lib.mkIf (!(isNull c.authEndpoint)) ''

View file

@ -179,6 +179,9 @@ so it involves more hops than a direct [OIDC integration](blocks-authelia.html#b
}
```
If PHP is used with fastCGI,
extra headers must be added by enabling the [`shb.nginx.vhosts.*.phpForwardAuth`](#blocks-nginx-options-shb.nginx.vhosts._.phpForwardAuth) option.
### Virtual Host Extra Config {#blocks-nginx-usage-extraconfig}
To add extra configuration to a virtual host,