Admin console does not work with reverse proxy

See original GitHub issue

Describe the bug

With a past Keycloak version (16.1.1), I was able to proxy everything Keycloak related (/admin, /auth) under the path /keycloak on my host. I currently struggle to achieve the same with 18.0.

Version

18.0

Expected behavior

I expect that /admin can be proxied under a path (e.g., /keycloak) on my host as before.

Actual behavior

Attempt 1: Use --hostname-path

I start Keycloak with kc.sh start proxy=edge --hostname-path=keycloak --http-enabled=true and set the hostname via ENV KC_HOSTNAME. My reverse proxy config is /keycloak -> http://local-keycloak:8080. Navigating to /keycloak shows the landing page and e.g., resources are correctly loaded from /keycloak/resources as expected. However, the href emitted for the admin console link does not honer the provided hostname-path and points to /admin on my host. Navigating manually to /keycloak/admin/master/console/ yields a broken page as the resources are now loaded from /resources on my host, what is quite strange as on the login page the --hostname-path was honored.

Attempt 2: Use --http-relative-path

I build Keycloak with --http-relative-path=keycloak and start Keycloak with kc.sh start proxy=edge --http-enabled=true and set the hostname via ENV KC_HOSTNAME. Reverse proxy setting is now /keycloak http://local-keycloak:8080/keycloak. Again, navigating to /keycloak shows the landing page and e.g., resources are correctly loaded from /keycloak/resources as expected. Clikcing on the admin console redirects me to /keycloak/admin/master/console/, but now the page is white and starts refreshing every couple of seconds.

How to Reproduce?

Please refer to this repo I created to reproduce the problem.

Anything else?

While searching around, a couple of people suggested to use --hostname-admin but this gives me an unknown option error.

I see two ways to work around this:

  1. I go with attempt 1. and proxy /admin etc on my host to the container , however, this would make using the /keycloak path in the first place kind of useless.
  2. I move the keycloak to a dedicated subdomain e.g., auth.example.org and do not rely on proxied paths altogether, but this would require a couple of changes in production what I would really like to avoid.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
omasseaucommented, May 30, 2022

Problem solved for me after removing the KC_HOSTNAME_PORT=443 variable from the config :

KC_HTTP_ENABLED=true
KC_PROXY=passthrough
KC_HOSTNAME=localhost
KC_HOSTNAME_STRICT=false
KC_HOSTNAME_STRICT_HTTPS=false
KC_HTTP_RELATIVE_PATH=/auth

It now works both in http and https.

This is weird as when calling https://localhost/auth the port is by default 443, which clearly matches the value of KC_HOSTNAME_PORT. So I don’t understand why setting explicitely KC_HOSTNAME_PORT=443 is a problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keycloak Account Management Console not working with ...
1 Answer 1 · Make sure you have set the proxy-address-forwarding="true" value for the HTTP listener config of your keycloak server. · Make...
Read more >
Keycloak Admin console not accessible - Stack Overflow
I've installed the keycloak server and put it behind an nginx reverse proxy on the same machine. I've setup a letsencrypt cert for...
Read more >
Worklight Console can be accessed directly, but not from ... - IBM
Worklight Console can be accessed directly, but not from behind a reverse proxy - "The resource or service cannot be found" error.
Read more >
Admin Console 'Probe Configuration' not working using Proxy
We are facing a new issue with UIM 9.0.2,when trying to configure a probe from outside the Internet over a proxy connection to...
Read more >
Keycloak admin console in docker behind reverse proxy
I am trying to use Keycloak 19.0.1 on a docker container, with nginx 1.18.0 as a reverse proxy. Keycloak is started with: docker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found