2023-02-05 17:45:56 -05:00
|
|
|
## Version 2023/02/05 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample
|
2020-08-03 11:00:14 -04:00
|
|
|
# Make sure that your authelia container is in the same user defined bridge network and is named authelia
|
|
|
|
# Make sure that the authelia configuration.yml has 'path: "authelia"' defined
|
|
|
|
|
2023-02-01 12:50:56 -05:00
|
|
|
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
|
2020-08-03 11:00:14 -04:00
|
|
|
auth_request /authelia/api/verify;
|
2023-02-05 17:45:56 -05:00
|
|
|
## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal.
|
|
|
|
error_page 401 = @authelia_proxy_signin;
|
2023-02-01 12:50:56 -05:00
|
|
|
|
2023-02-01 20:35:23 -05:00
|
|
|
## 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.
|
2020-08-03 11:00:14 -04:00
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
2021-04-20 23:17:25 -04:00
|
|
|
auth_request_set $name $upstream_http_remote_name;
|
|
|
|
auth_request_set $email $upstream_http_remote_email;
|
2023-02-01 12:50:56 -05:00
|
|
|
|
2023-02-01 20:35:23 -05:00
|
|
|
## Inject the metadata response headers from the variables into the request made to the backend.
|
2020-08-03 11:00:14 -04:00
|
|
|
proxy_set_header Remote-User $user;
|
|
|
|
proxy_set_header Remote-Groups $groups;
|
2021-04-20 23:17:25 -04:00
|
|
|
proxy_set_header Remote-Name $name;
|
|
|
|
proxy_set_header Remote-Email $email;
|
2023-02-01 12:50:56 -05:00
|
|
|
|
2023-02-01 20:35:23 -05:00
|
|
|
## Include the Set-Cookie header if present.
|
|
|
|
auth_request_set $set_cookie $upstream_http_set_cookie;
|
|
|
|
add_header Set-Cookie $set_cookie;
|