title: Tomcat (8080) behind IIS (443) with Keycloak (8443) authentication: tomcat redirects to keycloak on 443 port instead of 8443
body: <p><strong>Use case:</strong>
  Due to specific restrictions, I need to configure the following configuration: </p>
  
  <ul>
  <li>Tomcat configured to use port 8080</li>
  <li>IIS configured to use port 443 (SSL)</li>
  <li>IIS redirect to Tomcat via ARR + URL redirect rule</li>
  <li>Keycloak standalone configured to use port 8443 (SSL)</li>
  <li>Access the application through a public domain and not the IP address (ie: www.myserver.com)</li>
  </ul>
  
  <p>The Tomcat application will be accessed using the IIS proxy:
  <a href="https://server/myapp" rel="nofollow noreferrer">https://server/myapp</a></p>
  
  <p>The Keycloak authentication will be accessed using directly the keycloak URL:
  <a href="https://server:8443/auth/" rel="nofollow noreferrer">https://server:8443/auth/</a>....</p>
  
  <p><strong>Problem:</strong>
  When I access keycloak directly using the 8443 secured port works great, but when I access the Java application via IIS proxy (443), the IIS/Tomcat is redirecting for the keycloak authentication to port 443 instead of port 8443. </p>
  
  <p><strong>Question:</strong>
  Are there any settings on IIS, Tomcat, or Keycloak that I am missing to make the tomcat redirect to the correct keycloak 8443 port for authentication?</p>
  
  <p>Ie:
  When adding to the browser the <a href="https://server/myapp" rel="nofollow noreferrer">https://server/myapp</a> URL, the tomcat application is redirecting (for authentication) to <a href="https://server/auth/" rel="nofollow noreferrer">https://server/auth/</a> instead of <a href="https://server:8443/auth/" rel="nofollow noreferrer">https://server:8443/auth/</a></p>
  
  <p><strong>IIS ARR configuration screenshot:</strong>
  <a href="https://i.stack.imgur.com/eJkqU.png" rel="nofollow noreferrer">IIS ARR settings</a></p>
  
  <p><strong>IIS Redirect rule configuration screenshot</strong>
  <a href="https://i.stack.imgur.com/BIjGN.png" rel="nofollow noreferrer">IIS Redirect rule</a></p>
  
  <p><strong>Deployment use-case screenshot</strong>
  <a href="https://i.stack.imgur.com/G7w3H.png" rel="nofollow noreferrer">Deployment use case diagram</a></p>