From c5ef5788e7e22a9fc8dbeb4d12e46b800ebf8d46 Mon Sep 17 00:00:00 2001 From: Dominik Guhr Date: Thu, 3 Feb 2022 09:29:56 +0100 Subject: [PATCH 1/3] Production readiness guide V1 Closes #9463 --- .../src/main/server/production-readiness.adoc | 39 +++++++++++++++++++ docs/guides/src/main/server/reverseproxy.adoc | 6 ++- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 docs/guides/src/main/server/production-readiness.adoc diff --git a/docs/guides/src/main/server/production-readiness.adoc b/docs/guides/src/main/server/production-readiness.adoc new file mode 100644 index 00000000000..fed603fc543 --- /dev/null +++ b/docs/guides/src/main/server/production-readiness.adoc @@ -0,0 +1,39 @@ +<#import "/templates/guide.adoc" as tmpl> +<#import "/templates/kc.adoc" as kc> +<#import "/templates/links.adoc" as links> + +<@tmpl.guide +title="Configuring Keycloak for production" +summary="Learn how to make Keycloak ready for production." +includedOptions=""> + +Keycloak is used in various production environments, from on-premise deployments spanning only a few thousand users to deployments serving millions of users with secure authentication and authorization. + +This guide walks you through the general aspects of setting up a production ready Keycloak environment. It focusses on the main concepts and aspects instead of the actual implementation, which depends on your actual environment, be it containerized, on-premise, GitOps or Ansible. The key aspects covered in this guide apply to all of these environments. + +== Enabling TLS +Keycloak exchanges sensitive data all the time, so all communication from and to Keycloak needs to be done through a secure communication channel. For that, you must enable HTTP over TLS, or HTTPS, to prevent several attack vectors. + +The <@links.server id="enabletls"/> and <@links.server id="outgoinghttp"/> guides will show you the appropriate configuration to set up secure communication channels for Keycloak. + +== Setting the hostname for Keycloak +Keycloak instances in production usually run in a private network, but Keycloak needs to expose different public facing endpoints to communicate with applications that will be secured. + +Learn in the <@links.server id="hostname"/> guide what the different endpoint categories are and how to configure the public hostname for them, depending on your specific environment. + +== Configure a reverse proxy +Apart from <>, production environments usually use a reverse proxy / load balancer component to separate and unify access to the companies network. Using such a component is recommended for Keycloak production deployments. + +In the <@links.server id="reverseproxy"/> guide you can find the available proxy communication modes in Keycloak and how to configure them. There's also a recommendation which paths should not be exposed to the public at all, and which Paths need to be exposed for Keycloak to be able to secure your applications. + +== Configure a production grade database +The used database for Keycloak is crucial for the overall performance, avilability, reliability and integrity of Keycloak. In the <@links.server id="db"/> guide you can find the supported database vendors and how to configure Keycloak to use them. + +== Run Keycloak in a cluster +You'd not want every login to fail when your Keycloak instance goes down, so typical production deployments consist of two or more Keycloak instances. + +Keycloak right now uses JGroups and Infinispan under the covers to provide a reliable, HA-ready stack to run in a clustered scenario. + +To find out more about using multiple nodes, the different caches and the right stack for your environment, see the <@links.server id="caching"/> guide. + + diff --git a/docs/guides/src/main/server/reverseproxy.adoc b/docs/guides/src/main/server/reverseproxy.adoc index c1b662235e8..eae7074361d 100644 --- a/docs/guides/src/main/server/reverseproxy.adoc +++ b/docs/guides/src/main/server/reverseproxy.adoc @@ -7,7 +7,7 @@ title="Configuring a reverse proxy" summary="Learn how to configure Keycloak together with a reverse proxy, api gateway, or load balancer." includedOptions="proxy proxy-*"> -Distributed environments frequently require the use of a reverse proxy. +Distributed environments frequently require the use of a reverse proxy. For Keycloak, your choice of proxy modes depends on the TLS termination in your environment. == Proxy modes @@ -33,7 +33,9 @@ To select the proxy mode, enter this command: <@kc.start parameters="--proxy "/> == Configure the reverse proxy -Make sure your reverse proxy is configured correctly by performing these actions: +Some Keycloak features rely on the assumption that the remote address of the HTTP request connecting to Keycloak is the real IP address of the clients machine. + +When you have a reverse proxy or loadbalancer in front of Keycloak, this might not be the case, so please make sure your reverse proxy is configured correctly by performing these actions: * Set the X-Forwarded-For and X-Forwarded-Proto HTTP headers. * Preserve the original 'Host' HTTP header. From 487352cece24247919b59f3440cdccf3d22a5b19 Mon Sep 17 00:00:00 2001 From: Dominik Guhr <89905860+DGuhr@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:57:24 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Stian Thorgersen --- docs/guides/src/main/server/production-readiness.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/src/main/server/production-readiness.adoc b/docs/guides/src/main/server/production-readiness.adoc index fed603fc543..fc3b06870b4 100644 --- a/docs/guides/src/main/server/production-readiness.adoc +++ b/docs/guides/src/main/server/production-readiness.adoc @@ -27,12 +27,12 @@ Apart from <>, production environments usuall In the <@links.server id="reverseproxy"/> guide you can find the available proxy communication modes in Keycloak and how to configure them. There's also a recommendation which paths should not be exposed to the public at all, and which Paths need to be exposed for Keycloak to be able to secure your applications. == Configure a production grade database -The used database for Keycloak is crucial for the overall performance, avilability, reliability and integrity of Keycloak. In the <@links.server id="db"/> guide you can find the supported database vendors and how to configure Keycloak to use them. +The database used by Keycloak is crucial for the overall performance, availability, reliability and integrity of Keycloak. In the <@links.server id="db"/> guide you can find the supported database vendors and how to configure Keycloak to use them. == Run Keycloak in a cluster You'd not want every login to fail when your Keycloak instance goes down, so typical production deployments consist of two or more Keycloak instances. -Keycloak right now uses JGroups and Infinispan under the covers to provide a reliable, HA-ready stack to run in a clustered scenario. +Keycloak uses JGroups and Infinispan under the covers to provide a reliable, HA-ready stack to run in a clustered scenario. When deployed to a cluster the embedded Infinispan server communication should be secured. Either by enabling authentication and encryption, or through isolating the network used for cluster communication. To find out more about using multiple nodes, the different caches and the right stack for your environment, see the <@links.server id="caching"/> guide. From 6ec60d1f6690a1bd41ed1027810a1b3def36d347 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Fri, 4 Feb 2022 15:18:44 +0100 Subject: [PATCH 3/3] Update docs/guides/src/main/server/production-readiness.adoc --- docs/guides/src/main/server/production-readiness.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/src/main/server/production-readiness.adoc b/docs/guides/src/main/server/production-readiness.adoc index fc3b06870b4..329fe14524e 100644 --- a/docs/guides/src/main/server/production-readiness.adoc +++ b/docs/guides/src/main/server/production-readiness.adoc @@ -24,7 +24,7 @@ Learn in the <@links.server id="hostname"/> guide what the different endpoint ca == Configure a reverse proxy Apart from <>, production environments usually use a reverse proxy / load balancer component to separate and unify access to the companies network. Using such a component is recommended for Keycloak production deployments. -In the <@links.server id="reverseproxy"/> guide you can find the available proxy communication modes in Keycloak and how to configure them. There's also a recommendation which paths should not be exposed to the public at all, and which Paths need to be exposed for Keycloak to be able to secure your applications. +In the <@links.server id="reverseproxy"/> guide you can find the available proxy communication modes in Keycloak and how to configure them. There's also a recommendation which paths should not be exposed to the public at all, and which paths need to be exposed for Keycloak to be able to secure your applications. == Configure a production grade database The database used by Keycloak is crucial for the overall performance, availability, reliability and integrity of Keycloak. In the <@links.server id="db"/> guide you can find the supported database vendors and how to configure Keycloak to use them.