Spring security redirects behind reverse proxy in kubernetes

7/15/2019

I have Spring Security application deployed in kubernetes without servlet context path. In ingress (nginx reverse proxy) I have rewrite rule:

for example /api/oauth-server/authorize -> /authorize

so my login page should be accessed via www.example.com/api/oauth-server/login from outside, but Spring Security redirects me to www.example.com/login. It is because my login page is on /login in application. I want Spring Security redirect me to www.example.com/api/oauth-server/login

How to solve this redirect issue behind the reverse proxy to make it work? This should be common issue, but I did not find any resource with practical info.

-- hiimjames
java
kubernetes
nginx
spring
spring-security

0 Answers