AuthUrl and AuthServerUrl in a reverse-proxy context.
I’m fighting with the auth panel in a keyCloak located behind a nginx reverse-proxy.
Everything is fine in the page since there are relative paths, except this:
Of course, since nginx enforces HTTPS, the http protocol is refused.
And it seems to come from there, at the beginning of the page, where js variables authUrl and authServerUrl are declared:
<script type="text/javascript">
var authServerUrl = 'http://<site>/auth';
var authUrl = 'http://<site>/auth';
var consoleBaseUrl = '/auth/admin/master/console/';
var resourceUrl = '/auth/resources/5w76l/admin/keycloak';
var masterRealm = 'master';
var resourceVersion = '5w76l';
</script>
There is no reference to these variables anywhere in the doc.
How is it possible to make these variables have the correct value (https://) or to have a relative path in this place?
Are you terminating the SSL/HTTPS session with your reverse proxy or do you want to handle keycloak the certificate? I use a set-up to terminate the session with a proxy and use http behind that one to reach the keycloak. In such case you just need to add the proxy-mode to the standalone Konfiguration.
Hello. Thank you four your answer.
nginx is the TLS endpoint for many sites behind it.
By adding the proxy-mode to the standalone configuration you want to tell adding the attribute proxy-address-forwarding=“true” to the http-listener element?
Like this:
I did it.
Nothing new,
The auth.js, in https:///auth/admin/master/console/, is always referenced by http and not through a relative path in the home page.
And you have no problem at all proxiing keycloak with nginx (TLS before and http behind)?
BTW, my keycloak version is the latest, the 9.0.3.
db
I added some stuff and I removed them.
For example, #proxy_redirect http:// https://;
I used it on another configuration, it was necessary but not in this case apparently.
I also played with a / at the en of the proxy_pass directive.
The standalone.xml is the one from the tar.gz except the proxy-address-forwarding=“true”.
Variables inside the standalone.xml are set from outside using -D flag.
Ah, and, as there is no variable in this part I had to change the address of the SMTP mailer at the end of the standalone.xml. That’s all.
And https MUST be lowercase.
I made a test yesterday with a HTTPS word (I read this somewhere) and it didn’t work. I then abandoned and requested an assistance.
Ok, it works now, there was definitively a trick.
Thank you again.