Skip to content

Commit 83bc8a3

Browse files
authored
Merge pull request #331 from linuxserver/driz-tik
Add Authentik configs, update Authelia configs
2 parents d838ef6 + b095dd7 commit 83bc8a3

File tree

9 files changed

+146
-38
lines changed

9 files changed

+146
-38
lines changed

README.md

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
335335

336336
## Versions
337337

338+
* **09.02.23:** - [Existing users should update:](https://github.com/linuxserver/docker-swag/blob/master/README.md#updating-configs) proxy.conf, authelia-location.conf and authelia-server.conf - Add Authentik configs, update Authelia configs.
338339
* **06.02.23:** - Add porkbun support back in.
339340
* **21.01.23:** - Unpin certbot version (allow certbot 2.x). !!BREAKING CHANGE!! We are temporarily removing the certbot porkbun plugin until a new version is released that is compatible with certbot 2.x.
340341
* **20.01.23:** - Rebase to alpine 3.17 with php8.1.

readme-vars.yml

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ app_setup_block: |
154154
155155
# changelog
156156
changelogs:
157+
- { date: "09.02.23:", desc: "[Existing users should update:](https://github.com/linuxserver/docker-swag/blob/master/README.md#updating-configs) proxy.conf, authelia-location.conf and authelia-server.conf - Add Authentik configs, update Authelia configs." }
157158
- { date: "06.02.23:", desc: "Add porkbun support back in." }
158159
- { date: "21.01.23:", desc: "Unpin certbot version (allow certbot 2.x). !!BREAKING CHANGE!! We are temporarily removing the certbot porkbun plugin until a new version is released that is compatible with certbot 2.x." }
159160
- { date: "20.01.23:", desc: "Rebase to alpine 3.17 with php8.1." }
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
## Version 2022/08/20 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample
1+
## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authelia-location.conf.sample
22
# 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
34
# Make sure that the authelia configuration.yml has 'path: "authelia"' defined
45

6+
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
57
auth_request /authelia/api/verify;
6-
auth_request_set $target_url $scheme://$http_host$request_uri;
8+
## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal.
9+
error_page 401 = @authelia_proxy_signin;
10+
11+
## Translate response headers from Authelia into variables
712
auth_request_set $user $upstream_http_remote_user;
813
auth_request_set $groups $upstream_http_remote_groups;
914
auth_request_set $name $upstream_http_remote_name;
1015
auth_request_set $email $upstream_http_remote_email;
16+
auth_request_set $authorization $upstream_http_authorization;
17+
auth_request_set $proxy_authorization $upstream_http_proxy_authorization;
18+
19+
## Inject the response header variables into the request made to the actual upstream
1120
proxy_set_header Remote-User $user;
1221
proxy_set_header Remote-Groups $groups;
1322
proxy_set_header Remote-Name $name;
1423
proxy_set_header Remote-Email $email;
15-
error_page 401 =302 https://$http_host/authelia/?rd=$target_url;
24+
proxy_set_header Authorization $authorization;
25+
proxy_set_header Proxy-Authorization $proxy_authorization;
26+
27+
## Include the Set-Cookie header if present.
28+
auth_request_set $set_cookie $upstream_http_set_cookie;
29+
add_header Set-Cookie $set_cookie;
Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
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
22
# 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
35

6+
# location for authelia subfolder requests
47
location ^~ /authelia {
8+
auth_request off; # requests to this subfolder must be accessible without authentication
59
include /config/nginx/proxy.conf;
610
include /config/nginx/resolver.conf;
711
set $upstream_authelia authelia;
812
proxy_pass http://$upstream_authelia:9091;
913
}
1014

15+
# location for authelia auth requests
1116
location = /authelia/api/verify {
1217
internal;
1318

19+
include /config/nginx/proxy.conf;
1420
include /config/nginx/resolver.conf;
1521
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+
1628
proxy_pass_request_body off;
17-
proxy_pass http://$upstream_authelia:9091;
1829
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;
1953

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;
5055
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authentik-location.conf.sample
2+
# Make sure that your authentik container is in the same user defined bridge network and is named authentik-server
3+
# Rename /config/nginx/proxy-confs/authentik.conf.sample to /config/nginx/proxy-confs/authentik.conf
4+
5+
## Send a subrequest to Authentik to verify if the user is authenticated and has permission to access the resource.
6+
auth_request /outpost.goauthentik.io/auth/nginx;
7+
## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal.
8+
error_page 401 = @goauthentik_proxy_signin;
9+
10+
## Translate response headers from Authentik into variables
11+
auth_request_set $authentik_username $upstream_http_x_authentik_username;
12+
auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
13+
auth_request_set $authentik_email $upstream_http_x_authentik_email;
14+
auth_request_set $authentik_name $upstream_http_x_authentik_name;
15+
auth_request_set $authentik_uid $upstream_http_x_authentik_uid;
16+
17+
## Inject the response header variables into the request made to the actual upstream
18+
proxy_set_header X-authentik-username $authentik_username;
19+
proxy_set_header X-authentik-groups $authentik_groups;
20+
proxy_set_header X-authentik-email $authentik_email;
21+
proxy_set_header X-authentik-name $authentik_name;
22+
proxy_set_header X-authentik-uid $authentik_uid;
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;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authentik-server.conf.sample
2+
# Make sure that your authentik container is in the same user defined bridge network and is named authentik-server
3+
# Rename /config/nginx/proxy-confs/authentik.conf.sample to /config/nginx/proxy-confs/authentik.conf
4+
5+
# location for authentik subfolder requests
6+
location ^~ /outpost.goauthentik.io {
7+
auth_request off; # requests to this subfolder must be accessible without authentication
8+
include /config/nginx/proxy.conf;
9+
include /config/nginx/resolver.conf;
10+
set $upstream_authentik authentik-server;
11+
proxy_pass http://$upstream_authentik:9000;
12+
}
13+
14+
# location for authentik auth requests
15+
location = /outpost.goauthentik.io/auth/nginx {
16+
internal;
17+
18+
include /config/nginx/proxy.conf;
19+
include /config/nginx/resolver.conf;
20+
set $upstream_authentik authentik-server;
21+
proxy_pass http://$upstream_authentik:9000/outpost.goauthentik.io/auth/nginx;
22+
23+
## Include the Set-Cookie header if present.
24+
auth_request_set $set_cookie $upstream_http_set_cookie;
25+
add_header Set-Cookie $set_cookie;
26+
27+
proxy_pass_request_body off;
28+
proxy_set_header Content-Length "";
29+
}
30+
31+
# Virtual location for authentik 401 redirects
32+
location @goauthentik_proxy_signin {
33+
internal;
34+
35+
## Set the $target_url variable based on the original request.
36+
set_escape_uri $target_url $scheme://$http_host$request_uri;
37+
38+
## Include the Set-Cookie header if present.
39+
auth_request_set $set_cookie $upstream_http_set_cookie;
40+
add_header Set-Cookie $set_cookie;
41+
42+
## Set $authentik_backend to route requests to the current domain by default
43+
set $authentik_backend $http_host;
44+
return 302 https://$authentik_backend/outpost.goauthentik.io/start?rd=$target_url;
45+
}

root/defaults/nginx/proxy.conf.sample

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/09/01 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/proxy.conf.sample
1+
## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/proxy.conf.sample
22

33
# Timeout if the real server is dead
44
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
@@ -25,11 +25,13 @@ proxy_set_header Host $host;
2525
proxy_set_header Proxy "";
2626
proxy_set_header Upgrade $http_upgrade;
2727
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28-
proxy_set_header X-Forwarded-Host $host:$server_port;
28+
proxy_set_header X-Forwarded-Host $host;
2929
proxy_set_header X-Forwarded-Method $request_method;
30+
proxy_set_header X-Forwarded-Port $server_port;
3031
proxy_set_header X-Forwarded-Proto $scheme;
3132
proxy_set_header X-Forwarded-Server $host;
3233
proxy_set_header X-Forwarded-Ssl on;
3334
proxy_set_header X-Forwarded-Uri $request_uri;
35+
proxy_set_header X-Original-Method $request_method;
3436
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
3537
proxy_set_header X-Real-IP $remote_addr;

root/defaults/nginx/site-confs/default.conf.sample

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/10/03 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/site-confs/default.conf.sample
1+
## Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/site-confs/default.conf.sample
22

33
# redirect all traffic to https
44
server {
@@ -29,6 +29,9 @@ server {
2929
# enable for Authelia (requires authelia-location.conf in the location block)
3030
#include /config/nginx/authelia-server.conf;
3131

32+
# enable for Authentik (requires authentik-location.conf in the location block)
33+
#include /config/nginx/authentik-server.conf;
34+
3235
location / {
3336
# enable for basic auth
3437
#auth_basic "Restricted";
@@ -40,6 +43,9 @@ server {
4043
# enable for Authelia (requires authelia-server.conf in the server block)
4144
#include /config/nginx/authelia-location.conf;
4245

46+
# enable for Authentik (requires authentik-server.conf in the server block)
47+
#include /config/nginx/authentik-location.conf;
48+
4349
try_files $uri $uri/ /index.html /index.php$is_args$args =404;
4450
}
4551

root/etc/s6-overlay/s6-rc.d/init-nginx-config/run

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ if [[ ! -f /config/nginx/authelia-server.conf ]]; then
1414
cp /defaults/nginx/authelia-server.conf.sample /config/nginx/authelia-server.conf
1515
fi
1616

17+
# copy authentik config files if they don't exist
18+
if [[ ! -f /config/nginx/authentik-location.conf ]]; then
19+
cp /defaults/nginx/authentik-location.conf.sample /config/nginx/authentik-location.conf
20+
fi
21+
if [[ ! -f /config/nginx/authentik-server.conf ]]; then
22+
cp /defaults/nginx/authentik-server.conf.sample /config/nginx/authentik-server.conf
23+
fi
24+
1725
# copy old ldap config file to new location
1826
if [[ -f /config/nginx/ldap.conf ]] && [[ ! -f /config/nginx/ldap-server.conf ]]; then
1927
cp /config/nginx/ldap.conf /config/nginx/ldap-server.conf

0 commit comments

Comments
 (0)