Apache 使用Spring secuity进行代理传递失败

Apache 使用Spring secuity进行代理传递失败,apache,mod-rewrite,spring-security,proxypass,Apache,Mod Rewrite,Spring Security,Proxypass,我已经编写了一套重定向规则 http://server.com/application/c/<UserIdValue> http://server.com/application/c/ 指向的url的类型 http://localserver.com/application/?userid=<UserIdValue> http://localserver.com/application/?userid= 我在apachehttpd.conf中编写了以下规则 <

我已经编写了一套重定向规则

http://server.com/application/c/<UserIdValue>
http://server.com/application/c/
指向的url的类型

http://localserver.com/application/?userid=<UserIdValue>
http://localserver.com/application/?userid=
我在apachehttpd.conf中编写了以下规则

<Location  /application>
  ProxyPassReverse http://server.com/application/ 
  RewriteEngine On

  RewriteCond %{REQUEST_URI} /c/ [NC]
  RewriteRule application/c/(.*)$ http://localserver.com/application/?userid=$1 [QSA,P]

ProxyPassReversehttp://server.com/application/ 
重新启动发动机
RewriteCond%{REQUEST_URI}/c/[NC]
重写规则应用程序/c/(.*)$http://localserver.com/application/?userid=$1[QSA,P]
通过这个,我可以访问登录页面和应用程序中的其他页面,但当我尝试在应用程序中登录/注销时,它会进入“localserver”位置

问题在于spring安全性检查、spring安全性注销。我不知道该怎么办


Spring security优先于代理通行证

要使其正常工作,您必须改变两件事:

  • 将ProxyPass/ProxyPassReverse行更改为不以尾随/结尾
  • 告诉您的应用程序服务器正确设置上下文(ProxyPassReverse不会为您更改表单上的URI)。如果您使用的是Tomcat,那么您可以通过编辑conf/server.xml,找到带有属性protocol=“HTTP/1.1”的标记,并添加两个新属性:proxyHost=“localserver.com”proxyPort=“80”(如果localserver.com和server.com在同一端口上运行,则不需要严格使用proxyPort=“80”)

  • 问题1的原因是Spring Security没有标准化URI,因此如果代理给您的应用程序服务器一个类似URI的URI,Spring Security拦截器将与之匹配,请注意,由于额外的斜杠,它是不同的,并拒绝拦截请求。

    第一条建议修复了我几个小时来一直在苦苦挣扎的一个问题。这么简单的事情,会让人头疼。