# Keycloak Https Redirection Issue

**URL:** <https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287>\
**Category:** Miscellanaeous\
**Created:** [November 24, 2021, 9:24am UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287 "2021-11-24T09:24:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xandar](https://avatars.discourse-cdn.com/v4/letter/x/22d042/32.png) [@Xandar](https://forum.keycloak.org/u/Xandar)\
**Post date:** [November 24, 2021, 9:24am UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/1 "2021-11-24T09:24:23Z")

</div>

I have a Javascript app which is integrated with Keycloak. I uploaded the keycloak to the web server using nginx. Now when I use https to access my app it shows me a screen after login by saying i.e. **The information you want to send is not secure This form is sent over a connection that is not completely secure. As a result, your information may be visible to others.**

 ![Image Attached](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/f/fcaef7b408fe930241c08aa9e6780df5612bcc98.png)  
and then after clicking on **Proceed** I am directed to the homepage.

Here is my javascript code:

```auto

<script src="https://weblink.com/auth/js/keycloak.js"></script>

    <script>
        var keycloak;
    
        function initKeycloak() {
            keycloak = Keycloak({
                realm: 'realmName',
                url: 'https://weblink.com/auth/',
                sslRequired: 'external',
                clientId: 'clientName',
                publicClient: 'public',
                confidentialPort: 0,
            });
            keycloak.init({onLoad: 'login-required'}).then(function (authenticated) {
                console.log("Authenticated");
            }).catch(function () {
                alert('failed to initialize');
            });
        }

```

I don’t know what’s the problem here.

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bpedersen2/32/3934_2.png) [@bpedersen2](https://forum.keycloak.org/u/bpedersen2)\
**Post date:** [November 24, 2021, 9:54am UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/2 "2021-11-24T09:54:48Z")

</div>

Are you using a self-signed certificate on that domain?

---

<div class="post-metadata">

**Author:** ![Xandar](https://avatars.discourse-cdn.com/v4/letter/x/22d042/32.png) [@Xandar](https://forum.keycloak.org/u/Xandar)\
**Post date:** [November 24, 2021, 10:03am UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/3 "2021-11-24T10:03:26Z")

</div>

Yes the domain is using Self Signed Certificate

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bpedersen2/32/3934_2.png) [@bpedersen2](https://forum.keycloak.org/u/bpedersen2)\
**Post date:** [November 24, 2021, 10:45am UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/4 "2021-11-24T10:45:26Z")

</div>

Then this warning is expected until you add an exception in the browser…

---

<div class="post-metadata">

**Author:** ![Xandar](https://avatars.discourse-cdn.com/v4/letter/x/22d042/32.png) [@Xandar](https://forum.keycloak.org/u/Xandar)\
**Post date:** [November 24, 2021, 12:46pm UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/5 "2021-11-24T12:46:58Z")

</div>

How will I add the exception?  
Isn’t there any other way to stop this exception?

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bpedersen2/32/3934_2.png) [@bpedersen2](https://forum.keycloak.org/u/bpedersen2)\
**Post date:** [November 24, 2021, 12:59pm UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/6 "2021-11-24T12:59:37Z")

</div>

That depends on the browser, normally there is a an ‘advanced option’ link somewhere. If not check the browser docs.

For a production system you should always use official certifcates, never self-signed ones.

---

<div class="post-metadata">

**Author:** ![ayoub96anbara](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/ayoub96anbara/32/4355_2.png) [@ayoub96anbara](https://forum.keycloak.org/u/ayoub96anbara)\
**Post date:** [November 26, 2021, 1:31pm UTC](https://forum.keycloak.org/t/keycloak-https-redirection-issue/12287/7 "2021-11-26T13:31:06Z")

</div>

I have run keycloak with HTTPS, this steps can help you:  
1- I setup HTTPS using certificate [https://certbot.eff.org/](https://certbot.eff.org/)  
2- I use keycloak image docker:

```auto
docker run -d --name keycloak_15.0.2 -e KEYCLOAK_USER=kc-admin \
-e KEYCLOAK_PASSWORD=1234Pass \
-e PROXY_ADDRESS_FORWARDING=true -p 9090:8080 jboss/keycloak:15.0.2

```

3-My nginx configuration:

```auto
location /auth/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-Proto $scheme;
       proxy_pass http://127.0.0.1:9090;
       proxy_buffer_size 128k;
       proxy_buffers 4 256k;
       proxy_busy_buffers_size 256k;
       client_max_body_size 16m;
    }

```
