Keycloak 26.0.2 - mixed content issue - https -> http

Hi,

I have problems when deploying a custom Keycloak docker image in the cloud.

Dockerfile:

FROM quay.io/keycloak/keycloak:latest AS builder

# Enable health and metrics support
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true

# Configure a database vendor
ENV KC_DB_VENDOR=postgres
ENV KC_DB=postgres
COPY ./providers/keycloak-magic-link-0.29-SNAPSHOT.jar /opt/keycloak/providers/

RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
WORKDIR /opt/keycloak
# for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore

# change these values to point to a running postgres instance
ENV KC_HTTP_ENABLED=true
ENV KEYCLOAK_SSL_REQUIRED=none
ENV KC_HOSTNAME=localhost

ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start", "--optimized"]

Environment variables:

KC_BOOTSTRAP_ADMIN_PASSWORD=*****
KC_BOOTSTRAP_ADMIN_USERNAME=*****
KC_DB_PASSWORD=****
KC_DB_URL=*****
KC_DB_USERNAME=*****
KC_HOSTNAME=keycloak-******.onrender.com
KC_HOSTNAME_STRICT=false
KC_HOSTNAME_STRICT_HTTPS=true
KC_HTTP_ENABLED=false
KC_PROXY=edge

When trying to load the admin console it returns the error below.

The error in the console loading happens when making requests to https://keycloak-.onrender.com/resources/master/admin/en, but if I try to access the same URL directly, it works, including using HTTP, which is redirected correctly to HTTPS.

I’ve researched a lot and tried some environment variables I found in similar post issues, but none has worked so far. The docker image works fine if I run it locally using Docker desktop.

Thank you in advance for any input.

Hey tom, proxy=edge is deprecated. If you sit behind a reverse proxy, look this up: Using a reverse proxy - Keycloak

1 Like

Thanks a lot, @gmolaire! After reading the documentation, I got it working. The protocol https was missing in the hostname variable. I also removed the deprecated prox variable.

1 Like