Skip to content

Commit

Permalink
KEYCLOAK-11728 New default hostname provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst committed Nov 11, 2019
1 parent 837e636 commit 3784cef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 8 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,16 @@ Keycloak supports vault implementation for [Kubernetes secrets](https://kubernet

## Misc

### Specify frontend base URL

To set a fixed base URL for frontend requests use the following environment value (this is highly recommended in production):

* `KEYCLOAK_FRONTEND_URL`: Specify base URL for Keycloak (optional, default is retrieved from request)

### Specify hostname

This environment variable is deprecated, use `KEYCLOAK_FRONTEND_URL` instead.

To set a fixed hostname for Keycloak use the following environment value. This is highly recommended in production.

* `KEYCLOAK_HOSTNAME`: Specify hostname for Keycloak (optional, default is retrieved from request, recommended in production)
Expand Down
7 changes: 2 additions & 5 deletions server/tools/cli/hostname.cli
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/subsystem=keycloak-server/spi=hostname:write-attribute(name=default-provider, value="${keycloak.hostname.provider:request}")
/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.hostname,value="${keycloak.hostname.fixed.hostname:localhost}")
/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.httpPort,value="${keycloak.hostname.fixed.httpPort:-1}")
/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.httpsPort,value="${keycloak.hostname.fixed.httpsPort:-1}")
/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.alwaysHttps,value="${keycloak.hostname.fixed.alwaysHttps:false}")
/subsystem=keycloak-server/spi=hostname:write-attribute(name=default-provider, value="${keycloak.hostname.provider:default}")
/subsystem=keycloak-server/spi=hostname/provider=fixed/:add(properties={hostname => "${keycloak.hostname.fixed.hostname:localhost}",httpPort => "${keycloak.hostname.fixed.httpPort:-1}",httpsPort => "${keycloak.hostname.fixed.httpsPort:-1}",alwaysHttps => "${keycloak.hostname.fixed.alwaysHttps:false}"},enabled=true)
8 changes: 7 additions & 1 deletion server/tools/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ file_env() {
unset "$fileVar"
}

SYS_PROPS=""

##################
# Add admin user #
##################
Expand All @@ -41,8 +43,12 @@ fi
# Hostname #
############

if [ "$KEYCLOAK_FRONTEND_URL" != "" ]; then
SYS_PROPS+="-Dkeycloak.frontendUrl=$KEYCLOAK_FRONTEND_URL"
fi

if [ "$KEYCLOAK_HOSTNAME" != "" ]; then
SYS_PROPS="-Dkeycloak.hostname.provider=fixed -Dkeycloak.hostname.fixed.hostname=$KEYCLOAK_HOSTNAME"
SYS_PROPS+="-Dkeycloak.hostname.provider=fixed -Dkeycloak.hostname.fixed.hostname=$KEYCLOAK_HOSTNAME"

if [ "$KEYCLOAK_HTTP_PORT" != "" ]; then
SYS_PROPS+=" -Dkeycloak.hostname.fixed.httpPort=$KEYCLOAK_HTTP_PORT"
Expand Down

0 comments on commit 3784cef

Please sign in to comment.