Skip to main content
Skip table of contents

Praktische Hinweise zur Einrichtung eines Reverse-Proxy-Servers

Hier finden Sie einige praktische Hinweise, um Ihnen die Einrichtung eines Reverse-Proxy-Servers zu erleichtern.

Szenario:

  • Verwendung von Authorization Code Flow

  • Anbindung an externen Identity Provider (z. B. Azure)

  • Verwendung des Adapters Keycloak Management

  • Einsatz der Admin-UI aus internem Netzwerk

Umsetzung:

  • keycloak_config.xml im X4-Installationsverzeichnis:

CODE
{

"connection": {

 "realm": "X4Realm",

 "auth-server-url": "https://[INTERN_HOST]/auth/",

 "resource": "X4",

  "credentials": {

"secret": "[SECRET]"

}

},

"webAppKeycloakAuthUrl": "https://[EXTERN_URL]/auth/"

}

Wenn INTERN_HOST = EXTERN_URL, fügen Sie EXTERN_URL zur Datei /ect/hosts mit dem lokalen IP hinzu.

  • Keycloak.conf in Keycloak:

CODE
# Basic settings for running in production. Change accordingly before deploying the server.

# Database



# The database vendor.

#db=postgres



# The username of the database user.

#db-username=keycloak



# The password of the database user.

#db-password=password



# The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.

#db-url=jdbc:postgresql://localhost/keycloak



# Observability



# If the server should expose metrics and healthcheck endpoints.

#metrics-enabled=true



# HTTPS

https-key-store-file=${kc.home.dir}/conf/kc.keystore

https-key-store-password=secret

https-port=443



# HTTP



# The proxy address forwarding mode if the server is behind a reverse proxy.

#proxy=edge



# Do not attach route to cookies and rely on the session affinity capabilities from reverse proxy

#spi-sticky-session-encoder-infinispan-should-attach-route=false



# Hostname for the Keycloak server.

#hostname=[EXTERN_URL]         <— Can be uncommented, if /etc/hosts entry is made

#hostname-admin=[INTERN_HOST]

hostname-strict=false



# Used HTTP host.

#http-host=[INTERN_HOST]

#http-enbaled=false



# Resources path prefix.

http-relative-path=/auth



# HTTP and HTTPS ports.

#http-port=8085

#https-port=8448



# Logging.

log=console,file

#log-file=${kc.home.dir}/log/keycloak.log

Weitere Hinweise:

  • Verwenden Sie ein SSL-Zertifikat für den Keycloak.
    Laden Sie bei Verwendung eines selbstsignierten Zertifikats die öffentliche .crt-Datei in dieses Verzeichnis: /c:/X4/jdk/bin/keytool -importcert -keystore cacerts -storepass changeit -alias kc -file kc.crt.
    Schalten Sie außerdem die Zertifikatvalidierung im Proxy-Server für die Keycloak-Weiterleitung ab.

So können Sie ein selbstsigniertes Zertifikat für die Verwendung in Keycloak anlegen:

  1. Legen Sie das Zertifikat an:

    XML
    sudo openssl req -x509 -nodes -days 530 -newkey rsa:2048 -keyout kc.key -out kc.crt -subj "/C=DE/ST=Baden-Württemberg/L=Ettlingen/O=SoftProject/CN=localhost" 

  2.  Importieren Sie das Zertifikat in den Keystore:

    XML
    sudo openssl pkcs12 -inkey kc.key -in kc.crt -export -out kc.p12 -passout pass:changeit -name kc

  3. Konvertieren Sie p12 in einen Java-Keystore: 

    XML
    /c:/X4/jdk/bin/keytool/keytool -importkeystore -srckeystore <source_keystoreFile> -srcstoretype PKCS12 -destkeystore <destination_keystoreFile>  -deststoretype JKS -srcstorepass mysecret -deststorepass mysecret -srcalias myalias -destalias myalias -srckeypass mykeypass -destkeypass mykeypass -noprompt

  • Führen Sie den Keycloak im Produktivmodus (PROD) aus. 

  • Fügen Sie die folgenden Header zum Proxy hinzu:

X-Forwarded-For=$HOST

X-Forwarded-Proto=„https“

X-Forwarded-Host=$HOST

  • Legen Sie die Root-URL für X4 Client in Keycloak wie folgt fest: https://[EXTERN_URL]/X4

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.