Java 带有Spring安全性的Apache/mod_jk

Java 带有Spring安全性的Apache/mod_jk,java,url-rewriting,spring-security,apache2,mod-jk,Java,Url Rewriting,Spring Security,Apache2,Mod Jk,我在使用mod_jk和Spring安全性时遇到了一些问题,以前的项目中都使用过,但现在我似乎无法让它正常工作 我在使用JBoss时遇到了一个相当典型的情况,但当我的web应用位于http://hostname/myapp 我想把它从浏览器中隐藏起来,这样所有的访问都会被删除http://hostname 在Apache中,我有两条规则:- # Remove double "myapp" in url RewriteRule ^/myapp/(.*) /$1 # Check to see if

我在使用mod_jk和Spring安全性时遇到了一些问题,以前的项目中都使用过,但现在我似乎无法让它正常工作

我在使用JBoss时遇到了一个相当典型的情况,但当我的web应用位于http://hostname/myapp 我想把它从浏览器中隐藏起来,这样所有的访问都会被删除http://hostname

在Apache中,我有两条规则:-

# Remove double "myapp" in url
RewriteRule ^/myapp/(.*) /$1

# Check to see if content can be served locally - rewrite back if not
RewriteCond /dir/to/static/content -f
RewriteRule ^/(.*) /myapp/$1 [PT]

JkMount /myapp/* loadbalancer
我已将Spring安全性剥离,使其尽可能简单:

<security:http auto-config="true">
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
当我尝试登录时

我的问题是:

这是一个需要配置的Spring安全问题,还是我的Apache不正确? 有人有一个工作配置,他们可以与我分享!
我已经为此挣扎了好几个小时,读了很多帖子,但都没能让它起作用。

来回答我自己的问题,将来可能帮助其他人。我不得不切换到mod_代理,而不是mod_jk

我的设置是这样的

<Proxy>
   Order deny,allow
   Allow from all
</Proxy>

RewriteCond /dir/to/static/content/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*) ajp://127.0.0.1:8009/myapp/$1 [P]
ProxyPassReverse /  http://myurl/myapp/
ProxyPassReverseCookiePath /myapp /
我的spring安全文件

<security:http auto-config="false" use-expressions="true" disable-url-rewriting="true">
   <security:intercept-url pattern="/app/login" access="permitAll" />
   <security:intercept-url pattern="/app/**" access="hasAnyRole('ROLE_USER', 'ROLE_ADMIN')" />
   <security:form-login
    login-page="/app/login"
    authentication-failure-url="/app/login?f=1"
    default-target-url="/app/map"/>
   <security:logout logout-url="/app/logout"/>
 </security:http>
我认为关键是ProxyPassReverseCookiePath语句

<Proxy>
   Order deny,allow
   Allow from all
</Proxy>

RewriteCond /dir/to/static/content/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*) ajp://127.0.0.1:8009/myapp/$1 [P]
ProxyPassReverse /  http://myurl/myapp/
ProxyPassReverseCookiePath /myapp /
<security:http auto-config="false" use-expressions="true" disable-url-rewriting="true">
   <security:intercept-url pattern="/app/login" access="permitAll" />
   <security:intercept-url pattern="/app/**" access="hasAnyRole('ROLE_USER', 'ROLE_ADMIN')" />
   <security:form-login
    login-page="/app/login"
    authentication-failure-url="/app/login?f=1"
    default-target-url="/app/map"/>
   <security:logout logout-url="/app/logout"/>
 </security:http>