How can I set the docker keycloak base url
as parameter ?
I have the following nginx reverse proxy configuration:
server {
listen 80;
server_name example.com;
location /keycloak {
proxy_pass http://example.com:8087/;
}
}
When I try to access http://example.com/keycloak/ I got a keycloak http redirect to http://example.com/auth/ instead of http://example.com/keycloak/auth/
Any ideas?
Just tested that @home, and actually multiple configuration additions are needed:
1/ Run the keycloak container with env
-e PROXY_ADDRESS_FORWARDING=true
as explained in the docs, this is required in a proxy way of accessing to keycloak:Also explained in this SO question
2/ Change the web-context inside keycloak's configuration file
$JBOSS_HOME/standalone/configuration/standalone.xml
Default keycloak configuration points to
auth
Then you could change it to
keycloak/auth
If you need to automate this for docker, just create a new keycloak image :
3/ Add some proxy information to nginx configuration (mostly for http / https handling)
If you are proxying requests from nginx to keycloak on same server, I recommend using
proxy_pass http://localhost:8087;
, and if not try to use a private network to avoid proxying through external web requests.Hope this helps
Building on @Francois Maturel's response: for the latest Keycloak (currently 4.8.x), I had to add an additional line to replace the
web-context
instandalone-ha.xml
as well:The reason is that the
docker-entrypoint.sh
startup script will usestandalone-ha.xml
configuration in addition tostandalone.xml
unless the-c
flag is passed. See here: https://github.com/jboss-dockerfiles/keycloak/blob/master/server/tools/docker-entrypoint.sh