I have a keycloak, react web and a spring boot app are living behind nginx.
The frontend (react) and the backend (spring boot) are calling the keycloak service over the nginx proxy at the flowing urls:
realms/.../..etc
admin/.../..etc
js/.../.../..etc
resources/.../...etc
All those urls are reverse proxing to:
Http://keylock:8180
I don’t want to implements multiple locations in nginx for all those urls!
I am thinking about url rewriting to
auth/realms/...
auth/dmin/..
…
Or another clean solution with regex, but i don’t know how.
2
Answers
this worked for me
You can use the rewrite module for this.
In fact, with this method, I get the second part of the url and proxy it.
For example, when request send to
/auth/realms/...
the url rewrite to/realms/...
and send it to keycloakhttp://keylock:8180/realms/...