Web アプリに Spring Security と Apache プロキシを使用しています。標準の mod_proxy を使用する場合はすべて問題ありませんが、AJP プロキシに切り替えると、Spring セキュリティ リダイレクトに問題が発生します。
アパッチ構成:
<VirtualHost *:80>
ServerName domain.com
ProxyPass / ajp://localhost:8009/Context/
ProxyPassReverse / ajp://localhost:8009/Context/
</VirtualHost>
http://domain.com/loginを呼び出すと、ログイン フォームが表示されます。
フォームを送信すると、http://domain.com/authにアクセスして認証されます。
次に、Spring Security は http://domain.com/index にリダイレクトする必要がありますが、代わりにhttp://domain.com/Context/indexにリダイレクトします。
そのコンテキストパスを取り除くにはどうすればよいですか? Spring Security がそれをどこにでも追加するのはなぜですか?
Spring Security サイトに同様の質問がありましたが、誰も答えませんでした。
http://forum.springsource.org/showthread.php?95141-Why-is-spring-security-include-the-context-path
PS Google がこの問題に関連するものを見つけられないのは奇妙に思えます。Spring Security + AJP を使用しているのは私だけですか? もしかして間違ったパターン?
解決:
<VirtualHost *:80>
ServerName domain.com
RewriteEngine on
RewriteRule ^/Context/(.*)$ /$1 [R=301]
ProxyPass / ajp://localhost:8009/Context/
ProxyPassReverse / ajp://localhost:8009/Context/
</VirtualHost>