Home > Enterprise >  Cannot access keycloak admin pannel after connect to postgresql in docker
Cannot access keycloak admin pannel after connect to postgresql in docker

Time:05-02

It works fine when the postgresql database is not connected.But when I configure postgresql, I can get to the keycloak home page, but when I click on the admin console, it goes blank and keeps loading in this page. https://sso.dora.im/admin/master/console/

This is my docker-compose.yml

version: '3'

services:
  keycloak:
    image: quay.io/keycloak/keycloak:latest
    command: start-dev --proxy passthrough
    environment:
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://***:5432/keycloak?sslmode=require
      KC_HOSTNAME: ***
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: keycloak_password
      DB_SCHEMA: public
      KEYCLOAK_ADMIN: ***
      KEYCLOAK_ADMIN_PASSWORD: ***
    env_file: .env
    container_name: ${SERVER}
    hostname: ${HOST}
    labels:
      - traefik.http.routers.${SERVER}.rule=Host(`${HOST}`)
      - traefik.http.routers.${SERVER}.tls=true
      - traefik.http.routers.${SERVER}.tls.certresolver=le
      - traefik.http.services.${SERVER}.loadbalancer.server.port=${PORT}
    networks:
      traefik:
        aliases:
          - ${SERVER}

networks:
  traefik:
    external: true

After initializing the postgresql database,it started.When I check the docker log, it has no error.

CodePudding user response:

So... "admin login page goes blank" can have multiple causes. Please try the following:

  1. at the moment (Keycloak 17.0.1, 18) there's a Bug/UX issue in Keycloaks hostnameprovider / the way we load the authServerUrl / authUrl in JS. You would have to also set the hidden variable KC_HOSTNAME_STRICT_HTTPS=false. Keycloak team is working on this.

  2. Your Hostname does not get validated to be correct, but browsers have problems with incorrect hostnames. so please make sure you have a valid hostname setup in KC_HOSTNAME, e.g. all-lowercase, lesser than 253 chars, no _ etc. (reference: e.g. RFC952 , without the port (use http-port/https-port if you want standard 80/443 on your proxy or the hostname-port for non-standard port on proxy.)

For the database part: I really don't think it has something to do with it. Your startup logs would help in that case, so starting with e.g. KC_LOG_LEVEL=INFO,org.hibernate:debug or sth.

  • Related