helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

cannot enter admin console after new installation of keycloak chart v9.0.1

Open YoshieraHuang opened this issue 6 years ago • 26 comments

I upgraded the chart to v9.0.1. I used chrome to enter the keycloak pages. However i cannot enter the admin console. Here is the error at browser console:

Mixed Content: The page at 'https://auth.pims.private/auth/admin/master/console/' was loaded over HTTPS, but requested an insecure script 'http://auth.pims.private/auth/js/keycloak.js?version=bouyi'. This request has been blocked; the content must be served over HTTPS.

Screen Capture_select-area_20200730213123

It seems that the secure page is forbidden to access insecure contents in chrome. Is this a bug of this charts or the keycloak application?

Here is my custom values for chart:

extraEnv: |
  - name: KEYCLOAK_USER
    value: pims_private
  - name: KEYCLOAK_PASSWORD
    value: XXXXXX
serviceAccount:
  create: true
ingress:
  enabled: true
  annotations:
    # cert-manager to sign certificate
    cert-manager.io/cluster-issuer: ca-cluster-issuer
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-origin: "*.pims.private"
  rules:
  - host: auth.pims.private
    paths: [/]
  tls:
  - hosts:
    - auth.pims.private
    secretName: keycloak-cert

postgresql:
  postgresqlPassword: XXXXXXX
  persistence:
    storageClass: managed-nfs-storage
    enabled: true

YoshieraHuang avatar Jul 30 '20 13:07 YoshieraHuang

Encountering same issue.

ifalex avatar Jul 30 '20 21:07 ifalex

Same issue here

gallagth avatar Aug 03 '20 11:08 gallagth

Looks like they removed the proxy forwarding option: https://github.com/codecentric/helm-charts/commit/8b8044aa4458ca4a71d5420a503bedb2444ed605#diff-f287956fb12d7d7c321c313e858d887aL102

Maybe we gotta set the env var instead? Just like they say we have to do with username/pass.

CalamarBicefalo avatar Aug 03 '20 15:08 CalamarBicefalo

Try adding this @ifalex @gallagth @YoshieraHuang

extraEnv: |
    - name: PROXY_ADDRESS_FORWARDING
      value: "true"

make sure your proxy or whatever is doing SSL termination is forwarding headers.

UPDATE I messed up keycloak instances... I actually cannot get to set PROXY_ADDRESS_FORWARD into the docker container which basically is what's making my KC instance to cause the exception reported above.

UPDATE Quoting the boolean seemed to set the env var.

CalamarBicefalo avatar Aug 03 '20 16:08 CalamarBicefalo

I ran into this exact same issue. Running chart v9.0.1 on k8s using nginx-ingress chart v1.41.2. I have found a workaround that confirms PROXY_ADDRESS_FORWARDING=true will fix the issue:

$ kubectl edit statefulset -n keycloak keycloak
# add the following to .spec.template.spec.containers.0.env:
  - name: PROXY_ADDRESS_FORWARDING
    value: "true"

And you are able to admin keycloak. When done through helm (.Values.extraEnv), you will run into a bug in [values.schema.json](/blob/master/charts/keycloak/values.schema.json), which states that extraEnv should be a string, not an array.

I have created a PR that fixes the latter, which formally could be considered a fix for the original issue. Personally, I would prefer some default settings that mimic the pre-9.x.x behaviour, in which this proxy address forwarding does not need manual setting.

jonkerj avatar Aug 03 '20 19:08 jonkerj

Hi guys, I do solve the problems according to solution @jonkerj. Solution of @CalamarBicefalo cannot work. An error will emit whenever you upgrade or install. It seems env values like true or false must be quoted in keycloak. After all, thank you very much !

YoshieraHuang avatar Aug 04 '20 05:08 YoshieraHuang

To your point @YoshieraHuang @jonkerj quoting the bool works in the envars so you do not have to mingle with the stateful set. I updated the request, now it definitely works for me.

CalamarBicefalo avatar Aug 04 '20 09:08 CalamarBicefalo

Sure, that will probably work, but adding the environment as a multiline "yaml-like" string instead of proper YAML feels very unusual to me. In this way, you cannot leverage the validation capabilities of Helm. I'd recommend my changes to the values spec instead :-)

jonkerj avatar Aug 04 '20 10:08 jonkerj

I fully agree with you @jonkerj just saying that for a more "long term" approach, rather than editing the statefulset a viable workaround is configuring the var in the helm values that way.

CalamarBicefalo avatar Aug 04 '20 16:08 CalamarBicefalo

Thanks all, that fixed my issue as well. also the boolean value has to be quoted.

sct10876 avatar Aug 06 '20 01:08 sct10876

Hello all, I have the same issue and was able to fix that with your solution, thank you much.

Here is what I found while searching for the solution. (oh man, I lost a whole day with this issue)

The returned HTML from "https://keycloak.minikube/auth/admin/master/console/" contains some relative but also absolute paths with HTTP without SSL. This leads to the mentioned error, where the page tries to load insecured content from a secured context:

    <script type="text/javascript">
        var authServerUrl = 'http://keycloak.minikube/auth';
        var authUrl = 'http://keycloak.minikube/auth';
        var consoleBaseUrl = '/auth/admin/master/console/';
        var resourceUrl = '/auth/resources/evdwy/admin/keycloak';
        var masterRealm = 'master';
        var resourceVersion = 'evdwy';
    </script>
...
    <script src="http://keycloak.minikube/auth/js/keycloak.js?version=evdwy" type="text/javascript"></script>

See authServerUrl, authUrl and the keycloak.js.

It is not clear for me, why keycloak puts absolute paths here, but it works now.

Thanks and best regards, Paul

palsch avatar Aug 09 '20 17:08 palsch

I'd like you to all read the section on upgrading. The chart no longer does anything special. Please refer to the documentation of the Keycloak docker image for configuration options. https://github.com/codecentric/helm-charts/tree/master/charts/keycloak#from-chart-versions--900

unguiculus avatar Aug 13 '20 21:08 unguiculus

Closing as solved.

unguiculus avatar Aug 28 '20 08:08 unguiculus

I'd like you to all read the section on upgrading. The chart no longer does anything special. Please refer to the documentation of the Keycloak docker image for configuration options. https://github.com/codecentric/helm-charts/tree/master/charts/keycloak#from-chart-versions--900

Indeed, but for someone who didn't knew that something special was done in previous versions this is quite a complicated problem to analyze, and to find a fix for. And it may not be obvious that this is linked to a reverse proxy setup as explained here: https://github.com/codecentric/helm-charts/tree/master/charts/keycloak#running-keycloak-behind-a-reverse-proxy I would say that some info in the upgrade section would be relevant?

Xendar avatar Feb 18 '21 10:02 Xendar

Hi All I used to install keycloak using the k8s crd/operator, once done, i faced the issue issue related to Mixed Content: The page at 'https://MyDomain.com/auth/admin/master/console/' was loaded over HTTPS, but requested an insecure script 'http://MyDomain.com/auth/js/keycloak.js?version=bouyi'. This request has been blocked; the content must be served over HTTPS. I figured out that the PROXY_ADDRESS_FORWARDING is already defined to True in the sts Env section.

For my setup i have an external nginx reverse proxy, behind it i have another nginx ingress controller, and behind it i have the famous keycloak.

In fact am configuring domains, TLS/SSL on the external nginx, after that the traffic is forwarded to the internal nginx ingress controller and at the end forwarded to the keycloak pods.

Could anyone helps here to resolve the issue !

mootezbessifi avatar Apr 12 '21 10:04 mootezbessifi

I'm using keycloak image bitnami/keycloak:13.0.1-debian-10-r3 the env variable to set is:

  - name: KEYCLOAK_PROXY_ADDRESS_FORWARDING
    value: "true"

MohamedZ3kri avatar Jun 21 '21 16:06 MohamedZ3kri

if setting PROXY_ADDRESS_FORWARDING=true still not work, Just try KEYCLOAK_FRONTEND_URL=https://{{ URL }}/auth.

In my case, (On premise) Metal LB + nginx controller (helm) + keycloak with TLS secret (helm) was working with PROXY_ADDRESS_FORWARDING. But, (EKS) AWS NLB + custom nginx controller + keycloak (helm) need to be set KEYCLOAK_FRONTEND_URL.

fyi. keycloak version is 15.0.2 +You could make it work as changing nginx config, too.

tyg03485 avatar Sep 16 '21 05:09 tyg03485

AWS EKS set up require

KEYCLOAK_FRONTEND_URL=https://{{ URL }}/auth

@tyg03485 Thank you! I spent 3 days on resolving it

sturfee-petrl avatar Sep 26 '21 16:09 sturfee-petrl

Thank you very much @tyg03485 works on Azure App Services adding it to the Configuration --> Application Settings

KEYCLOAK_FRONTEND_URL=https://{{ URL }}/auth

optionsgithubuser avatar Sep 28 '21 23:09 optionsgithubuser

if you are using bitnami container image cannot evaluate KEYCLOAK_FRONTEND_URL. so

... KEYCLOAK_EXTRA_ARGS="-Dkeycloak.frontendUrl=https://${{ url }}"

kty1965 avatar Nov 01 '21 13:11 kty1965