# How to setup Keycloack behind a sub-domain over an https

**URL:** <https://forum.keycloak.org/t/how-to-setup-keycloack-behind-a-sub-domain-over-an-https/6029>\
**Category:** Configuring the server\
**Created:** [November 18, 2020, 10:15pm UTC](https://forum.keycloak.org/t/how-to-setup-keycloack-behind-a-sub-domain-over-an-https/6029 "2020-11-18T22:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumit](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kumit](https://forum.keycloak.org/u/kumit)\
**Post date:** [November 18, 2020, 10:15pm UTC](https://forum.keycloak.org/t/how-to-setup-keycloack-behind-a-sub-domain-over-an-https/6029/1 "2020-11-18T22:15:43Z")

</div>

Hello folks,

I am playing with Keycloak setup want to achieve the following things:

- Setup a keycloak service

- Use it behind HTTPS

- Use a sub-domain to point to the server

I have set up the server on digital ocean using a docker image. But that’s with HTTPS turned off. At this point, it’s accessible using HTTP and the IP address.

At this point I would have wanted to get some certs and use that, it would have solved half of the problem-- having HTTPS, though that would still be behind an IP.

But then I couldn’t find a free CA which gives certificates for IP address. So, I got a domain to use.

* * *

At this point, I thought I would use Nginx as a reverse proxy, will point a sub-domain to Nginx, and reroute the requests to Keycloak. I found a sensible plan but a poor execution.

(I should warn you that I am self-taught and new to many things here. Precisely-- Docker, Digital Ocean, Keycloak and Nginx 😛 )

- I got Nginx to route to Keycloak endpoint i.e http:///ip (Nginx is running on default port) to  
http:///ip:port/auth

- Glad about this minuscule success, I pointed sub-domain to Nginx. Now we have http:///sub.domain.com pointing to http:///ip:port/auth

- I also got certificates for Nginx from Let’sEncrypt. Thanks to their easy to follow steps.

Now coming to the poor execution part:

At this point, I have a https:///sub.domain.com pointing https:///ip:port/auth which is all nice and intended.  
But as soon as I click on admin I see the following flaws:

- The hyperlink is pointing to http:///ip:port/auth/a/b/c instead of http:///sub.domain/auth/a/b/c. So we definitely have something **wrong with the Nginx config.**

- The hyperlink is also **http** ://ip:port/auth/a/b/c instead of **https** which is kinda expected but not where I want to reach.

- Best way to configure the components:

These are the parts I am stuck at and would appreciate it a lot if anyone can help me with these.

I know it’s a lot to read and process but if you kind-hearted point me in the right directions, I will go, read and apply those.

And as a thank you note, I will be willing to buy you a coffee and would write a blog post with the steps to do all these for others to use.

Thanks, for staying till here,  
xoxo

---

<div class="post-metadata">

**Author:** ![kumit](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kumit](https://forum.keycloak.org/u/kumit)\
**Post date:** [November 19, 2020, 7:06pm UTC](https://forum.keycloak.org/t/how-to-setup-keycloack-behind-a-sub-domain-over-an-https/6029/2 "2020-11-19T19:06:00Z")

</div>

Got this figured out, will be writing a how-to for this. In hindsight, looks like not so complex and I have been missing some minor but important details.

---

<div class="post-metadata">

**Author:** ![wilhiamopyt](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/wilhiamopyt/32/7773_2.png) [@wilhiamopyt](https://forum.keycloak.org/u/wilhiamopyt)\
**Post date:** [February 23, 2023, 6:42pm UTC](https://forum.keycloak.org/t/how-to-setup-keycloack-behind-a-sub-domain-over-an-https/6029/3 "2023-02-23T18:42:31Z")

</div>

Mano você tem que passar na hora de inicializar o keycloak sua URL pra ele aceitar conexões daquela url tem uma chave de env pra isso da uma olhada na documentação
