问题描述
|
我们在Squid代理后面有一个带有Spring Security的Spring 3应用程序。问题是Spring只知道内部的鱿鱼URL,因此在
example.com/login
成功登录后,而不是重定向到example.com/home
,它会重定向到internal.example.com
。
有谁知道如何处理这种情况?
我的配置:
<security:http use-expressions=\"true\" auto-config=\"true\">
<security:intercept-url pattern=\"/\" access=\"hasRole(\'ROLE_ANONYMOUS\') or hasRole(\'ROLE_GENERAL_ADMINISTRATION\')\"/>
<security:intercept-url pattern=\"/**\" access=\"hasRole(\'ROLE_GENERAL_ADMINISTRATION\')\"/>
<security:intercept-url pattern=\"/static/**\" filters=\"none\"/>
<security:logout invalidate-session=\"true\" logout-url=\"/logout\" logout-success-url=\"/\"/>
<security:form-login login-page=\"/\" default-target-url=\"/dashboard\"/>
<security:anonymous/>
</security:http>
编辑:
在我的情况下,管理员错误地设置了mod_jk,因此使用squid和上述配置可以正常进行。
解决方法
我在Apache HTTP Reverse代理后面有一个具有Spring安全性的Web应用程序和一些愚蠢的应用程序,其行为类似于您在上文中所述,我们的解决方案是使用
mod_rewrite模块
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
无论如何,您说的很奇怪,因为正确的Spring安全配置应该使用相对的url,而与天气无关,在URL中使用内部或外部主机。
如果您配置URL
<security:form-login login-page=\"//login.jsp\" login-processing-url=\"/login\" always-use-default-target=\"true\"/>
在内部或外部URL中的行为应相同,这听起来像是配置问题。
, 我有一个类似的问题,在我的(当前是PHP)应用程序之前有一个nginx反向代理,但是其他人建议修复URL的工作是在代理上完成的,例如http://www.informit.com/articles/article.aspx?p=169534:
响应头重新映射。响应标头可能包含
明确指向内容Web服务器的信息。一
示例是用于重定向的\“ Location:\”标头。的
反向代理服务器重新映射\“ Location:\”字段,替换为
使用自己的地址引用内容Web服务器。
还有一个相关问题的答案:“使用spring的少数服务重定向到https”。