[KC 17.x.x] How to access admin UI from port-forwarded/internal URL / prevent redirect from internal url to KC_HOSTNAME

One thing I forgot to mention: set the “frontend URL” in the master realm to the admin URL (Note: you need the scheme here like http(s)://〜).

Reference: frontendUrl and adminUrl - how to restrict admin console to internal IP only?

However, changing the port number require a slightly tricky configuration. if you want to use localhost:8080 and localhost:8081, start with the following command, then add “http://localhost:8081” to the “frontend URL” of the master realm.

docker run -e KC_HOSTNAME=localhost -e KC_HOSTNAME_PORT=8080 -e KC_SPI_HOSTNAME_DEFAULT_ADMIN=localhost -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -p 8080:8080 -p 8081:8080 quay.io/keycloak/keycloak:17.0.1 start-dev