title: Keycloak redirect too many times in my loadbalance services
body: <p>I'm trying to use keycloak in my load balance service with Nginx.</p>
  <p>But when I call service API, I received the error &quot;Too Many Redirects&quot; in browser.</p>
  <p>I guess this process should be:</p>
  <pre><code>1. Request load-balanced to service A 
  2. Keycloak in service A redirect to login page
  3. Login with password &amp; username
  ----------------The above is correct----------------------------------
  4. Keycloak redirect to the original page but **load-balance to service B**
  5. Keycloak in service B redirect to login page
  6. Auto login without password
  7. Keycloak redirect to the original page but load-balance to service A
  8. Keycloak in service A redirect to login page
  9. Auto login without password
  10. Then loop forever...
  </code></pre>
  <p><a href="https://i.stack.imgur.com/nTWoB.png" rel="nofollow noreferrer">bug</a></p>
  <p>How should I change my keycloak config and fix the bug?</p>
  <p>nginx.conf:</p>
  <pre><code>    http {
        upstream backend{
            server 127.0.0.1:8001 weight=1;
            server 127.0.0.1:8002 weight=1;
        }
        
        ...
        ...
        
        server {
            listen       80;
            server_name  localhost;
  
            location / {
                proxy_pass http://backend;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
            
            ...
            ...
  
        }
       }
  
  </code></pre>
  <p>And Springboot keycloak config in the application.properties:</p>
  <pre><code>server.port=8002 # modify by command line
  
  keycloak.auth-server-url=http://172.20.51.25:8080/auth
  keycloak.realm=autocv
  keycloak.public-client=true
  keycloak.resource=oauthtest
  
  keycloak.securityConstraints[0].authRoles[0]=aps
  keycloak.securityConstraints[0].securityCollections[0].name= common
  keycloak.securityConstraints[0].securityCollections[0].patterns[0]=/*
  </code></pre>
  <p><a href="https://i.stack.imgur.com/wVYbD.png" rel="nofollow noreferrer">keycloak client config</a></p>