I use Spring Security and Apache proxy for a web app. When using standard mod_proxy everything is OK, but after switching to AJP proxy there appears a problem with Spring security redirects.
Apache config:
<VirtualHost *:80>
ServerName domain.com
ProxyPass / ajp://localhost:8009/Context/
ProxyPassReverse / ajp://localhost:8009/Context/
</VirtualHost>
When I call http://domain.com/login I see a login form.
When I submit the form I go to http://domain.com/auth and get authenticated.
Then Spring Security should redirect to http://domain.com/index but it redirects instead to http://domain.com/Context/index
How can I get rid of that context path? Why Spring Security adds it everywhere?
There was a similar question on Spring Security site but no one answered it:
http://forum.springsource.org/showthread.php?95141-Why-is-spring-security-including-the-context-path
P.S. It seems strange that Google doesn't find anything more related to this problem. Am I the only one who uses Spring Security + AJP? Maybe it's a wrong pattern?
Solution:
<VirtualHost *:80>
ServerName domain.com
RewriteEngine on
RewriteRule ^/Context/(.*)$ /$1 [R=301]
ProxyPass / ajp://localhost:8009/Context/
ProxyPassReverse / ajp://localhost:8009/Context/
</VirtualHost>