There are many questions like this I can find in the internet but none of the solutions provided worked.
I am using jboss/keycloak:14.0.0
docker image. The following properties are set in my ConfigMap
:
KEYCLOAK_FRONTEND_URL: /mycontext/access-management
PROXY_ADDRESS_FORWARDING: "true"
Please note that, change the KEYCLOAK_FRONTEND_URL
to an absolute URL like this https://mycompany.com/mycontext/access-managemen
makes no difference.
Now the ingress has been defined as below:
Path: /mycontext/access-management(/|$)(.*)
Rewrite To: /$2
Annotations:
ingress.kubernetes.io/ssl-redirect: "False"
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header X-Request-ID $request_id;
proxy_set_header X-Trace-ID $request_id;
gzip off;
nginx.ingress.kubernetes.io/proxy-connect-timeout: "180"
nginx.ingress.kubernetes.io/proxy-read-timeout: "180"
nginx.ingress.kubernetes.io/proxy-send-timeout: "180"
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/server-snippet: |
add_header X-Request-ID $request_id;
add_header X-Trace-ID $request_id;
nginx.org/redirect-to-https: "True"
What happens is very strange. See below it shows you where it takes me when I hit a URL:
Go to [server]/mycontext/access-management =takes you to=> [server]/auth
Go to [server]/mycontext/access-management/auth =takes you to=> [server]/mycontext/access-management/auth (works fine)
As you can see the second link works fine and you can see the Keycloak Welcome page with a number of links in it. One of the links is Administration Console
that is broken. If you hover your mouse the link is [server]/mycontext/access-management/admin
instead of [server]/mycontext/access-management/auth/admin
(comparing it with my local Keycloak server). Now if we ignore the link and put the right path in the address bar as [server]/mycontext/access-management/auth/admin
another strange thing happens and that changes the URL to [server]/auth/mycontext/access-management/admin/master/console/
.
I really don't understand what is happening here. Setting KEYCLOAK_FRONTEND_URL
on my local also breaks the links.
I have tried to change the rewrite
annotation of the ingress to /mycontext/access-management/$2
but this configuration doesn't work at all.
In the Keycloak documentation here it talks about a property named adminUrl
, however, setting -DadminUrl
or -Dkeycloak.adminUrl
seems to be ignored completely by the docker image when using JAVA_OPTS_APPEND
according to JBoss documentation page.
What have I missed here? Is there anything that I have missed in my configuration?
Please note that, we have no choice other than exposing it under a context-path followed by the name (i.e. /mycontext/access-management
). This is because of both our client requirements as well as the fact that we have many micro-services deployed under /mycontext
each of which has its own ingress configuration.
Any help is appreciated.