docker-swag/root/defaults/nginx/authelia-location.conf.sample

36 lines
1.9 KiB
Plaintext
Raw Normal View History

## Version 2023/02/01 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample
2020-08-03 15:00:14 +00: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
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
2020-08-03 15:00:14 +00:00
auth_request /authelia/api/verify;
## Set the $target_url variable based on the original request.
set_escape_uri $target_url $scheme://$http_host$request_uri;
## Save the upstream response headers from Authelia to variables.
2020-08-03 15:00:14 +00:00
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;
## Inject the response headers from the variables into the request made to the backend.
2020-08-03 15:00:14 +00:00
proxy_set_header Remote-User $user;
proxy_set_header Remote-Groups $groups;
proxy_set_header Remote-Name $name;
proxy_set_header Remote-Email $email;
## Set $authelia_backend to route requests to the current domain by default
set $authelia_backend $http_host;
## In order for Webauthn to work with multiple subdomains Authelia must operate on a separate subdomain
## To use Authelia on a separate subdomain:
## * comment the $authelia_backend line above
## * rename /config/nginx/site-conf/authelia.conf.sample to /config/nginx/site-conf/authelia.conf
## * make sure that your dns has a cname set for authelia
## * uncomment the $authelia_backend line below and change example.com to your domain
## * restart the swag container
#set $authelia_backend authelia.example.com;
## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal.
error_page 401 =302 https://$authelia_backend/authelia/?rd=$target_url;