# Keycloak in AWS with ALB

**URL:** <https://forum.keycloak.org/t/keycloak-in-aws-with-alb/8610>\
**Category:** Getting advice\
**Tags:** authentication, oidc\
**Created:** [April 20, 2021, 3:44pm UTC](https://forum.keycloak.org/t/keycloak-in-aws-with-alb/8610 "2021-04-20T15:44:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![torquemada163](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/torquemada163/32/2678_2.png) [@torquemada163](https://forum.keycloak.org/u/torquemada163)\
**Post date:** [April 20, 2021, 3:44pm UTC](https://forum.keycloak.org/t/keycloak-in-aws-with-alb/8610/1 "2021-04-20T15:44:17Z")

</div>

Hi!  
I installed two EC2 instances, each running Keycloak in standalone-ha mode with one RDS database. I put AWS Application Load Balancer in front of the instants.  
Scheme:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/b/bbe84720e3682956449a52aac0e77ebe8e527c4d.png)

Configured Discourse test forum with OpenID plugin for Keycloak authentication. And from that moment on the weirdness began…  
I go to the main page of the test forum:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/3/3011b8f04fca7767308115b012e1ddcf659d3680.png)

I click Login and go to the Keycloak instance that AWS ALB selects:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/1/102c49529ba45319c7693d215427512d22660da8.png)

I log in there and return me to the main page of the forum with the following error:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/3/315de50cdeb1336000fa15e5898412e379cb4b6a.png)

After several cycles “go to the main page of the forum → refresh the page → click Login” a miracle happens - suddenly the session is picked up! And I enter the forum:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/8/820730d1f8da39d9ee68284979e9887549bd64eb.png)

AWS ALB settings:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/b/b1b94cc8b6983a298915f11c94f3c1f13b53bf1b.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/5/5e1d8fba486925a8c8f03ad3e00153268a29bbe1.png)

AWS ALB Listeners:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/9/91c35927b2ce74439cc68e152601a4b5ad3494ca.png)

AWS ALB Target Group:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/4/4616dc51c95f8c70aedea3b68e7a160321701a84.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/c/c7ba63f6a25e67671388716688640b177b9f4408.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/2/25a299d6e914a206c1f13e90c7d0b902c836c82c.png)

I’m sure this is some kind of problem in the ALB-Keycloak bundle.  
Because when I turn off one of the two targets in the ALB Target Group, any - the problems go away, authorization occurs immediately, without errors.

Can someone tell me what I misconfigured? Thanks a lot in advance!
