1

以前のプロジェクトで機能していた Spring Security で mod_jk を使用すると、いくつかの問題が発生しますが、現在は機能していないようです。

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 を可能な限りシンプルにするために削除しました。

<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. 誰かが私と共有できる作業構成を持っています!

私はこれに数時間苦労しており、多くの投稿を読んでいますが、うまく機能させることができませんでした.

4

1 に答える 1

0

私自身の質問に答えて、将来他の人を助ける可能性があります。mod_jk ではなく mod_proxy に切り替える必要がありました。

私のセットアップは次のようになります

<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 ステートメントだと思います。

于 2012-07-25T07:47:58.120 に答える