From b8cf0e5dc4566022629e37949938fb28ff99df7f Mon Sep 17 00:00:00 2001 From: Dewi Roberts Date: Wed, 11 Jun 2025 13:50:18 +0100 Subject: [PATCH] website/docs: add host header dynamic property mapping (#15006) * Adds the property mapping and updates some language in the doc * Typos --- .../add-secure-apps/providers/proxy/index.md | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/website/docs/add-secure-apps/providers/proxy/index.md b/website/docs/add-secure-apps/providers/proxy/index.md index 1110846b8f..ad02d06cdf 100644 --- a/website/docs/add-secure-apps/providers/proxy/index.md +++ b/website/docs/add-secure-apps/providers/proxy/index.md @@ -141,7 +141,7 @@ In this mode, the regular expressions are matched against the Request's full URL ## Dynamic backend selection -You can configure the backend the proxy should access dynamically via _Scope mappings_. To do so, create a new _Scope mapping_, with a name and scope of your choice. As expression, use this: +You can configure the backend the proxy should access dynamically via scope mappings. To do this, create a scope mapping with a name and scope of your choice, and set the expression to: ```python return { @@ -151,11 +151,11 @@ return { } ``` -Afterwards, edit the _Proxy provider_ and add this new mapping. The expression is only evaluated when the user logs into the application. +Afterwards, edit the proxy provider and add this new mapping. The expression is only evaluated when the user logs into the application. ## Host header:ak-version[2025.6.1] -By default, the proxy provider will use forwarded Host header received from the client. Starting with authentik 2025.6.1, it is possible to dynamically adjust the Host header with a property mapping. +By default, the proxy provider will use the forwarded host header received from the client. Starting with authentik 2025.6.1, it is possible to dynamically adjust the host header with a property mapping. To do this, create a scope mapping with a name and scope of your choice, and set the expression to: ```python return { @@ -165,4 +165,20 @@ return { } ``` -Afterwards, edit the _Proxy provider_ and add this new mapping. The expression is only evaluated when the user logs into the application. +Afterwards, edit the proxy provider and add this new mapping. The expression is only evaluated when the user logs into the application. + +### Dynamically setting host header + +You can dynamically set the host header to match the **Internal host** value set on the proxy provider. To do this, create a scope mapping with a name and scope of your choice, and set the expression to: + +```python +from urllib.parse import urlparse +parsed_url = urlparse(provider.proxyprovider.internal_host) +return { + "ak_proxy": { + "host_header": parsed_url.netloc + } +} +``` + +Afterwards, edit the proxy provider and add this new mapping. The expression is only evaluated when the user logs into the application.