title: keycloak redirects urls to http instead of https
body: <p>I have a keycloak setup behind SSL terminating nginx proxy. When i try to access application secured using keycloak, keycloak generates url like following:</p>
  
  <pre><code>https://keycloak.mydomain.com/auth/realms/AdfsDemo/protocol/openid-connect/auth?client_id=adfs&amp;redirect_uri=http%3A%2F%2Fmyapp.mydomain.com%2Fsignin-oidc&amp;response_type=code&amp;scope=openid%20profile&amp;response_mode=form_post&amp;nonce=636603226928179925.MmUzYWEzMGYtNTAxOS00MTBkLTk4MWItMDU3MGY1NjAxOGViNzlhYmZiMDQtNTQyOC00Y2YzLTk2MjMtZjNjMWFjNTI1YzM3&amp;state=CfDJ8NQosUp9FsZBgifUu0XsVAEasSeKTitMPUM5yatTiQGf_Kz_X9CpQNPIHOkGr1hsgdErjhbw4ULINvCJgnFdWYctcIuhoyhOTt2Km3xy0qFh4o9gNFkPQlbEqc771MmVC2FUqUtvDqf8zChsyDDfGkxZ6Kc1y36I_3lFfzfubBAyXK0cEb_3AdZBMyDRp2WMykrarD8Z-0iGBk_q5Z8akYYHyCc7q-FSKxP1DW59nHpF8fM6P-S8SdVxvTW2dtEyV9UL6rlqD8dabNNJxhoaXEeBzwRh84it2vVlaaYpQ7d1ErZ51hpuzhG2gYSxnowMdQa8gfd8X1hs5HsgJXL-gCmBgTlxWNQfAy5DRpcX8Wi0&amp;x-client-SKU=ID_NET&amp;x-client-ver=2.1.4.0
  </code></pre>
  
  <p>I can access keycloak on https just fine. But when i try to access application secured using keycloak You will notice that redirect_uri generated by keycloak is http instead of https. </p>
  
  <p>Here is my nginx configuration</p>
  
  <pre><code>server {       
  listen 443  ssl;
  server_name  myapp.mydomain.com;
  ssl_certificate /etc/nginx/external/wildcard_mydomain_com.pem;
  ssl_certificate_key /etc/nginx/external/private.rsa;
  
  location / {                 
     proxy_set_header Host myapp.mydomain.com;         
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-Proto $scheme;       
     proxy_set_header X-Forwarded-Port 443;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                               
     proxy_pass http://172.30.5.28:8001;
   }
  }
  
  #Keycloak Service
  server {
  listen 443  ssl;
  server_name  keycloak.mydomain.com;  
  ssl_certificate /etc/nginx/external/wildcard_mydomain_com.pem;
  ssl_certificate_key /etc/nginx/external/private.rsa;
  location = / {
       return 301 https://keycloak.mydomain.com/auth; 
  }  
  location /auth {
     proxy_pass http://172.30.5.28:8080;        
     proxy_set_header Host keycloak.mydomain.com;  
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-Proto https;
     proxy_set_header X-Forwarded-Port 443;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;           
   }
  }
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks,
  Rahul</p>