|
1 | | -## Version 2022/09/22 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-server.conf.sample |
| 1 | +## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-server.conf.sample |
2 | 2 | # Make sure that your authelia container is in the same user defined bridge network and is named authelia |
| 3 | +# Rename /config/nginx/proxy-confs/authelia.conf.sample to /config/nginx/proxy-confs/authelia.conf |
| 4 | +# Make sure that the authelia configuration.yml has 'path: "authelia"' defined |
3 | 5 |
|
| 6 | +# location for authelia subfolder requests |
4 | 7 | location ^~ /authelia { |
| 8 | + auth_request off; # requests to this subfolder must be accessible without authentication |
5 | 9 | include /config/nginx/proxy.conf; |
6 | 10 | include /config/nginx/resolver.conf; |
7 | 11 | set $upstream_authelia authelia; |
8 | 12 | proxy_pass http://$upstream_authelia:9091; |
9 | 13 | } |
10 | 14 |
|
| 15 | +# location for authelia auth requests |
11 | 16 | location = /authelia/api/verify { |
12 | 17 | internal; |
13 | 18 |
|
| 19 | + include /config/nginx/proxy.conf; |
14 | 20 | include /config/nginx/resolver.conf; |
15 | 21 | set $upstream_authelia authelia; |
| 22 | + proxy_pass http://$upstream_authelia:9091/authelia/api/verify; |
| 23 | + |
| 24 | + ## Include the Set-Cookie header if present. |
| 25 | + auth_request_set $set_cookie $upstream_http_set_cookie; |
| 26 | + add_header Set-Cookie $set_cookie; |
| 27 | + |
16 | 28 | proxy_pass_request_body off; |
17 | | - proxy_pass http://$upstream_authelia:9091; |
18 | 29 | proxy_set_header Content-Length ""; |
| 30 | +} |
| 31 | + |
| 32 | +# Virtual location for authelia 401 redirects |
| 33 | +location @authelia_proxy_signin { |
| 34 | + internal; |
| 35 | + |
| 36 | + ## Set the $target_url variable based on the original request. |
| 37 | + set_escape_uri $target_url $scheme://$http_host$request_uri; |
| 38 | + |
| 39 | + ## Include the Set-Cookie header if present. |
| 40 | + auth_request_set $set_cookie $upstream_http_set_cookie; |
| 41 | + add_header Set-Cookie $set_cookie; |
| 42 | + |
| 43 | + ## Set $authelia_backend to route requests to the current domain by default |
| 44 | + set $authelia_backend $http_host; |
| 45 | + ## In order for Webauthn to work with multiple domains authelia must operate on a separate subdomain |
| 46 | + ## To use authelia on a separate subdomain: |
| 47 | + ## * comment the $authelia_backend line above |
| 48 | + ## * rename /config/nginx/proxy-confs/authelia.conf.sample to /config/nginx/proxy-confs/authelia.conf |
| 49 | + ## * make sure that your dns has a cname set for authelia |
| 50 | + ## * uncomment the $authelia_backend line below and change example.com to your domain |
| 51 | + ## * restart the swag container |
| 52 | + #set $authelia_backend authelia.example.com; |
19 | 53 |
|
20 | | - # Timeout if the real server is dead |
21 | | - proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; |
22 | | - |
23 | | - # [REQUIRED] Needed by Authelia to check authorizations of the resource. |
24 | | - # Provide either X-Original-URL and X-Forwarded-Proto or |
25 | | - # X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-Uri or both. |
26 | | - # Those headers will be used by Authelia to deduce the target url of the user. |
27 | | - # Basic Proxy Config |
28 | | - client_body_buffer_size 128k; |
29 | | - proxy_set_header Host $host; |
30 | | - proxy_set_header X-Original-URL $scheme://$http_host$request_uri; |
31 | | - proxy_set_header X-Real-IP $remote_addr; |
32 | | - proxy_set_header X-Forwarded-For $remote_addr; |
33 | | - proxy_set_header X-Forwarded-Method $request_method; |
34 | | - proxy_set_header X-Forwarded-Proto $scheme; |
35 | | - proxy_set_header X-Forwarded-Host $http_host; |
36 | | - proxy_set_header X-Forwarded-Uri $request_uri; |
37 | | - proxy_set_header X-Forwarded-Ssl on; |
38 | | - proxy_redirect http:// $scheme://; |
39 | | - proxy_http_version 1.1; |
40 | | - proxy_set_header Connection ""; |
41 | | - proxy_cache_bypass $cookie_session; |
42 | | - proxy_no_cache $cookie_session; |
43 | | - proxy_buffers 4 32k; |
44 | | - |
45 | | - # Advanced Proxy Config |
46 | | - send_timeout 5m; |
47 | | - proxy_read_timeout 240; |
48 | | - proxy_send_timeout 240; |
49 | | - proxy_connect_timeout 240; |
| 54 | + return 302 https://$authelia_backend/authelia/?rd=$target_url; |
50 | 55 | } |
0 commit comments