From 7c86d4d694deb80d92e65b0c43d7bc05024c3d2e Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 9 Jan 2022 21:01:11 +0300 Subject: [PATCH] keycloak service: allow to set empty frontend URL This together with extraConfig: { "subsystem=undertow"."server=default-server"."http-listener=default"."proxy-address-forwarding" = true; "subsystem=undertow"."server=default-server"."https-listener=https"."proxy-address-forwarding" = true; } Allows to run Keycloak behind a reverse proxy that provides X-Forwarded-* headers. (cherry picked from commit 97a0cf62f098d21a31c4dc03294e4919e88c225f) --- nixos/modules/services/web-apps/keycloak.nix | 6 +++++- nixos/modules/services/web-apps/keycloak.xml | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-apps/keycloak.nix b/nixos/modules/services/web-apps/keycloak.nix index b0cd1de0d41a..32c6f35e81c5 100644 --- a/nixos/modules/services/web-apps/keycloak.nix +++ b/nixos/modules/services/web-apps/keycloak.nix @@ -54,7 +54,11 @@ in frontendUrl = lib.mkOption { type = lib.types.str; - apply = x: if lib.hasSuffix "/" x then x else x + "/"; + apply = x: + if x == "" || lib.hasSuffix "/" x then + x + else + x + "/"; example = "keycloak.example.com/auth"; description = '' The public URL used as base for all frontend requests. Should diff --git a/nixos/modules/services/web-apps/keycloak.xml b/nixos/modules/services/web-apps/keycloak.xml index 8c3e35a051bc..cb706932f48f 100644 --- a/nixos/modules/services/web-apps/keycloak.xml +++ b/nixos/modules/services/web-apps/keycloak.xml @@ -85,7 +85,12 @@ The frontend URL is used as base for all frontend requests and must be configured through . It should normally include a trailing /auth - (the default web context). + (the default web context). If you use a reverse proxy, you need + to set this option to "", so that frontend URL + is derived from HTTP headers. X-Forwarded-* headers + support also should be enabled, using + respective guidelines.