Kategorien
Entwicklung

Configuring Nginx to have Keycloak handling auth requests in the same domain as your single page app and http api

If you want keycloak to handle auth requests in the same domain as you’re service your single page app (spa) and http api:
The prerender config comes from my prerendering proxy.
Keycloak is listening on port 4000 locally.

nginx config

You mount keycloak under /auth/

Then in keycloak.yml for the gatekeeper

And if using Angular with PWA

need to be added to the root {} to exclude treating the /auth/ prefix path as an angular internal route.

So it looks something like this for the default config:

And now you have keycloak running under the same domain as your SPA and http api.

Spread the love

Von Darko Luketic

I'm a freelance developer since 2004. I have been working professionally since 2000. My first contact with computers was the C64 at the age of 11, 1 year later I cracked games and another year later I wrote cracktros.
I worked with PHP professionally for 11 years, nowadays I prefer Angular, Go and Flutter, but I'm open minded. However I would dislike taking a step back to PHP.

My services are for hire.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.