2012-07-20 65 views
1

我在Spring Security中使用mod_jk時曾遇到過一些問題,這些問題曾在以前的項目上工作過,但我似乎無法使其工作。與Spring Security的Apache/mod_jk

我有使用JBoss一個相當典型的情況(但可能很容易被Tomcat)的時候,我的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 

我已經剝去我的春節,安全是儘可能簡單:

<security:http auto-config="true"> 
<security:intercept-url pattern="/**" access="ROLE_USER" /> 
</security:http> 

在我的web.xml

<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 

的問題是,沒有使用Spring安全(即。拆下springSecurityFilterChain)這工作得很好,但它包括我得到這樣

Reason: Authentication method not supported: GET 

問題,當我嘗試登錄

我的問題是:

  1. 這是一個Spring Security的問題需要配置,還是我的Apache不正確?
  2. 有沒有人有一個工作配置,他們可以與我分享!

我一直在努力與這幾個小時,閱讀很多帖子,但我沒有設法得到它的工作。

回答

0

回答我自己的問題,可能會幫助其他人在未來。我不得不切換到mod_proxy而不是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/

我的春節,安全文件

<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聲明。