From 0cc47e692281dce54955c009fc639ab2aec7a94b Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 9 Feb 2023 18:32:49 -0600 Subject: [PATCH] Additional config comments and consolidation --- .../nginx/authelia-location.conf.sample | 19 ++++++++----------- .../nginx/authelia-server.conf.sample | 15 +++++++-------- .../nginx/authentik-location.conf.sample | 1 + .../nginx/authentik-server.conf.sample | 9 ++++++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/root/defaults/nginx/authelia-location.conf.sample b/root/defaults/nginx/authelia-location.conf.sample index e7e07eb..c48ef6f 100644 --- a/root/defaults/nginx/authelia-location.conf.sample +++ b/root/defaults/nginx/authelia-location.conf.sample @@ -1,5 +1,6 @@ -## Version 2023/02/05 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample +## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample # Make sure that your authelia container is in the same user defined bridge network and is named authelia +# Rename /config/nginx/proxy-confs/authelia.conf.sample to /config/nginx/proxy-confs/authelia.conf # Make sure that the authelia configuration.yml has 'path: "authelia"' defined ## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource. @@ -7,25 +8,21 @@ auth_request /authelia/api/verify; ## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal. error_page 401 = @authelia_proxy_signin; -## Save the upstream authorization response headers from Authelia to variables. -auth_request_set $authorization $upstream_http_authorization; -auth_request_set $proxy_authorization $upstream_http_proxy_authorization; - -## Inject the authorization response headers from the variables into the request made to the backend. -proxy_set_header Authorization $authorization; -proxy_set_header Proxy-Authorization $proxy_authorization; - -## Save the upstream metadata response headers from Authelia to variables. +## Translate response headers from Authelia into variables auth_request_set $user $upstream_http_remote_user; auth_request_set $groups $upstream_http_remote_groups; auth_request_set $name $upstream_http_remote_name; auth_request_set $email $upstream_http_remote_email; +auth_request_set $authorization $upstream_http_authorization; +auth_request_set $proxy_authorization $upstream_http_proxy_authorization; -## Inject the metadata response headers from the variables into the request made to the backend. +## Inject the response header variables into the request made to the actual upstream proxy_set_header Remote-User $user; proxy_set_header Remote-Groups $groups; proxy_set_header Remote-Name $name; proxy_set_header Remote-Email $email; +proxy_set_header Authorization $authorization; +proxy_set_header Proxy-Authorization $proxy_authorization; ## Include the Set-Cookie header if present. auth_request_set $set_cookie $upstream_http_set_cookie; diff --git a/root/defaults/nginx/authelia-server.conf.sample b/root/defaults/nginx/authelia-server.conf.sample index b744419..742f21e 100644 --- a/root/defaults/nginx/authelia-server.conf.sample +++ b/root/defaults/nginx/authelia-server.conf.sample @@ -1,9 +1,11 @@ -## Version 2023/02/05 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-server.conf.sample +## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-server.conf.sample # Make sure that your authelia container is in the same user defined bridge network and is named authelia +# Rename /config/nginx/proxy-confs/authelia.conf.sample to /config/nginx/proxy-confs/authelia.conf # Make sure that the authelia configuration.yml has 'path: "authelia"' defined # location for authelia subfolder requests location ^~ /authelia { + auth_request off; # requests to this subfolder must be accessible without authentication include /config/nginx/proxy.conf; include /config/nginx/resolver.conf; set $upstream_authelia authelia; @@ -19,15 +21,12 @@ location = /authelia/api/verify { set $upstream_authelia authelia; proxy_pass http://$upstream_authelia:9091/authelia/api/verify; - ## Headers - proxy_set_header Content-Length ""; + ## Include the Set-Cookie header if present. + auth_request_set $set_cookie $upstream_http_set_cookie; + add_header Set-Cookie $set_cookie; - ## Basic Proxy Configuration proxy_pass_request_body off; - client_body_buffer_size 128k; - - ## Advanced Proxy Configuration - send_timeout 5m; + proxy_set_header Content-Length ""; } # Virtual location for authelia 401 redirects diff --git a/root/defaults/nginx/authentik-location.conf.sample b/root/defaults/nginx/authentik-location.conf.sample index 32c9b53..5571c45 100644 --- a/root/defaults/nginx/authentik-location.conf.sample +++ b/root/defaults/nginx/authentik-location.conf.sample @@ -1,5 +1,6 @@ ## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authentik-location.conf.sample # Make sure that your authentik container is in the same user defined bridge network and is named authentik-server +# Rename /config/nginx/proxy-confs/authentik.conf.sample to /config/nginx/proxy-confs/authentik.conf ## Send a subrequest to Authentik to verify if the user is authenticated and has permission to access the resource. auth_request /outpost.goauthentik.io/auth/nginx; diff --git a/root/defaults/nginx/authentik-server.conf.sample b/root/defaults/nginx/authentik-server.conf.sample index 9f482c3..8bbadca 100644 --- a/root/defaults/nginx/authentik-server.conf.sample +++ b/root/defaults/nginx/authentik-server.conf.sample @@ -1,5 +1,6 @@ ## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authentik-server.conf.sample # Make sure that your authentik container is in the same user defined bridge network and is named authentik-server +# Rename /config/nginx/proxy-confs/authentik.conf.sample to /config/nginx/proxy-confs/authentik.conf # location for authentik subfolder requests location ^~ /outpost.goauthentik.io { @@ -19,10 +20,12 @@ location = /outpost.goauthentik.io/auth/nginx { set $upstream_authentik authentik-server; proxy_pass http://$upstream_authentik:9000/outpost.goauthentik.io/auth/nginx; - add_header Set-Cookie $auth_cookie; - auth_request_set $auth_cookie $upstream_http_set_cookie; + ## Include the Set-Cookie header if present. + auth_request_set $set_cookie $upstream_http_set_cookie; + add_header Set-Cookie $set_cookie; + proxy_pass_request_body off; - proxy_set_header Content-Length ""; + proxy_set_header Content-Length ""; } # Virtual location for authentik 401 redirects