Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak Enable Maintenance Mode [closed]

Tags:

keycloak

How do I enable maintenance mode in KC, which means redirecting customer dashboards to a single page, in this case the user accounts dashboard will redirect to maintenance page?

so for example

accouts

and the other Keycloack customer dashboards will be redirect to something like

enter image description here

this my be done manually by toggle some option?

like image 282
mohamed hamada Avatar asked Dec 04 '25 01:12

mohamed hamada


1 Answers

I had a similar request and found a way to make it "sort of maintainable" for us.
But in my case, I had an NGINX reverse proxy running in front of keycloak.

  1. To do Maintenance, we "disable" the Realm in Keycloak Keycloak Disable Realm Setting

  2. Any request to the disabled realm returns HTTP Status 400, so we react on this in the NGINX reverse proxy config and return our "Maintenance Page"

proxy_intercept_errors on;

error_page 400 /maintenance.html;

location = /maintenance.html {
 internal;
 root /usr/share/nginx/html;
}

In my case, we host the "Maintenance Page" directly on the NGINX host.
But you could aswell return a temporary redirect like

proxy_intercept_errors on;

error_page 400 @maintenance;

location @maintenance {
  return 302 https://yoursite.com/maintenance
}

But this is not a perfect solution.

Ideally, I want my "Testaccounts-Audience" still be able to log in. So that we can verify the new config works as expected. And all other users e.g. "Productionaccounts-Audience" to receive a "Maintenance Page".

If someone can propose a good solution for this - keeping the realm "enabled" only for a test-audience, but redirect all other users, I'd appreciate it.

Regards, Erich

like image 186
Erich Neumayer Avatar answered Dec 07 '25 01:12

Erich Neumayer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!