2012-01-10 97 views
0

在登錄時,我的應用程序從443到80重定向: 原始URL是https://myhost.com/myapp/login.jsp 但是當我提交URL的https://myhost.com/myapp/j_spring_security_check被調用,並在登錄成功,嘗試連接到HTTPS://myhost.com:/MYAPP/爲什麼端口80在https中添加了Spring Security?

的URL的https://myhost.com/myapp/login.jsp調用Apache服務器。 這個apache用http(端口11080)叫做tomcat。

登錄操作與春季安全處理與配置:

<?xml version="1.0" encoding="UTF-8"?> 

<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
         http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd"> 
    <global-method-security secured-annotations="enabled"> 
    </global-method-security> 
    <http auto-config="true"> 
     <intercept-url pattern="/faces/secure/**" access="ROLE_ADMIN" /> 
     <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
     <form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?login_error=1"/> 
     <logout logout-success-url="/index.jsp"/> 
     <concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/> 
    </http> 
    <authentication-provider> 
     <jdbc-user-service data-source-ref="dataSource"/> 
    </authentication-provider> 
</beans:beans> 

此問題僅與登錄和註銷行爲,所以我覺得春季安全的問題。

一切正常,也沒有重定向當原始URL不使用默認的HTTPS端口443:HTTPS://myhost.com:12345/MYAPP/login.jsp的

一切正常,也當Apache用協議ajp稱爲Tomcat。

不幸的是,我要呼籲端口443和Tomcat與HTTP協議的Apache。

螺紋Spring Security Https Wrong Port幾乎是我的問題,只是我不以https叫Tomcat的,但HTTP。

用於連接

我的Tomcat的配置是:

<Connector port="11080" maxHttpHeaderSize="8192" 
      maxThreads="150" minSpareThreads="25" maxSpareThreads="75" 
      enableLookups="false" redirectPort="8443" acceptCount="100" 
      connectionTimeout="20000" disableUploadTimeout="true" /> 

<Connector port="11009" 
      enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> 
+0

請張貼您的tomcat連接器配置。內部服務器配置可能存在問題(用於重定向)。當您使用AJP時,它的作用更加可能。 – 2012-01-10 21:10:36

回答

0

接受的答案是建議依靠Microsoft特定標頭的自定義閥(前端Https)。相反,您應該使用已提供的RemoteIpValve並依靠事實上的標準x轉發原始標頭。

原因AJP代理工作,沒有額外的努力是,它是一個二進制協議,所以Web服務器/負載平衡器和Tomcat之間沒有HTTP調用,因此沒有模式/端口變化的問題。