Hello,
BW version: 1.6.12-rc2
I am using bunkerweb with Authentik forward-auth. Below are the configuration that I apply to the containers where I want forward-auth (in addition to basic reverse proxy settings that are not shown here).
This works:
bunkerweb.REVERSE_PROXY_AUTH_REQUEST: /outpost.goauthentik.io/auth/nginx
bunkerweb.REVERSE_PROXY_AUTH_REQUEST_SET: $$auth_cookie $$upstream_http_set_cookie;$$authentik_username $$upstream_http_x_authentik_username;$$authentik_groups $$upstream_http_x_authentik_groups;$$authentik_entitlements $$upstream_http_x_authentik_entitlements;$$authentik_email $$upstream_http_x_authentik_email;$$authentik_name $$upstream_http_x_authentik_name;$$authentik_uid $$upstream_http_x_authentik_uid
bunkerweb.REVERSE_PROXY_HEADERS: X-authentik-username $$authentik_username;X-authentik-groups $$authentik_groups;X-authentik-entitlements $$authentik_entitlements;X-authentik-email $$authentik_email;X-authentik-name $$authentik_name;X-authentik-uid $$authentik_uid
bunkerweb.REVERSE_PROXY_HEADERS_CLIENT: Set-Cookie $$auth_cookie
bunkerweb.REVERSE_PROXY_URL_999: /outpost.goauthentik.io
bunkerweb.REVERSE_PROXY_HOST_999: http://authentik-server:9000
bunkerweb.REVERSE_PROXY_HEADERS_999: "X-Original-URL $$scheme://$$http_host$$request_uri;Content-Length \"\""
bunkerweb.REVERSE_PROXY_HEADERS_CLIENT_999: Set-Cookie $$auth_cookie
bunkerweb.REVERSE_PROXY_AUTH_REQUEST_SET_999: $$auth_cookie $$upstream_http_set_cookie
bunkerweb.REVERSE_PROXY_PASS_REQUEST_BODY_999: no
bunkerweb.REVERSE_PROXY_INTERCEPT_ERRORS: no
bunkerweb.ERRORS: 401=@goauthentik_proxy_signin
bunkerweb.CUSTOM_CONF_SERVER_HTTP_goauthentik_signin: |
location @goauthentik_proxy_signin {
internal;
add_header Set-Cookie $$auth_cookie;
return 302 /outpost.goauthentik.io/start?rd=$$scheme://$$http_host$$request_uri;
}
This fails, it shows a nginx error 401:
bunkerweb.INTERCEPTED_ERROR_CODES: 400 403 404 405 413 429 500 501 502 503 504
bunkerweb.REVERSE_PROXY_AUTH_REQUEST: /outpost.goauthentik.io/auth/nginx
bunkerweb.REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL: "$$scheme://$$host/outpost.goauthentik.io/start?rd=$$scheme%3A%2F%2F$$host$$request_uri"
bunkerweb.REVERSE_PROXY_AUTH_REQUEST_SET: $$auth_cookie $$upstream_http_set_cookie;$$authentik_username $$upstream_http_x_authentik_username;$$authentik_groups $$upstream_http_x_authentik_groups;$$authentik_entitlements $$upstream_http_x_authentik_entitlements;$$authentik_email $$upstream_http_x_authentik_email;$$authentik_name $$upstream_http_x_authentik_name;$$authentik_uid $$upstream_http_x_authentik_uid
bunkerweb.REVERSE_PROXY_HEADERS_CLIENT: Set-Cookie $$auth_cookie
bunkerweb.REVERSE_PROXY_HEADERS: X-authentik-username $$authentik_username;X-authentik-groups $$authentik_groups;X-authentik-entitlements $$authentik_entitlements;X-authentik-email $$authentik_email;X-authentik-name $$authentik_name;X-authentik-uid $$authentik_uid
bunkerweb.REVERSE_PROXY_URL_999: /outpost.goauthentik.io
bunkerweb.REVERSE_PROXY_HOST_999: http://authentik-server:9000
bunkerweb.REVERSE_PROXY_HEADERS_999: "X-Original-URL $$scheme://$$http_host$$request_uri;Content-Length \"\""
bunkerweb.REVERSE_PROXY_HEADERS_CLIENT_999: Set-Cookie $$auth_cookie
bunkerweb.REVERSE_PROXY_AUTH_REQUEST_SET_999: $$auth_cookie $$upstream_http_set_cookie
bunkerweb.REVERSE_PROXY_PASS_REQUEST_BODY_999: no
For the above config, I took inspiration from bunkerweb/examples/authentik/autoconf.yml at master · bunkerity/bunkerweb · GitHub
It appears that REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL is not generating error_page 401directive (I could not find it in the resulting nginx config).
To fix it, I had to do a custom config as shown in the working example.
Additionnally, I recommend avoiding to write app1.example.com in your example. Making it non app-specific allows to do anchor and alias to all apps that would require forward-auth, making much cleaner compose files.