Apache 当使用https时,Spring Security会继续重定向到http

Apache 当使用https时,Spring Security会继续重定向到http,apache,tomcat,spring-mvc,ssl,spring-security,Apache,Tomcat,Spring Mvc,Ssl,Spring Security,在我登录或注销之后,Spring不断将我重定向到http页面。向页面添加需要channel=“https”只会导致重定向循环。这在我的本地计算机上运行良好,但是这个项目是在apache和负载平衡器下设置的 <http pattern="/services/**" create-session="stateless" entry-point-ref="basicAuthAwareAuthenticationEntryPoint"> <http-ba

在我登录或注销之后,Spring不断将我重定向到http页面。向页面添加
需要channel=“https”
只会导致重定向循环。这在我的本地计算机上运行良好,但是这个项目是在apache和负载平衡器下设置的

<http pattern="/services/**" create-session="stateless"
        entry-point-ref="basicAuthAwareAuthenticationEntryPoint">
        <http-basic />
        <port-mappings>
            <port-mapping http="8009" https="8443"/>
            <port-mapping http="80" https="443"/>
       </port-mappings>
       <intercept-url pattern="/services/**" access="ROLE_SERVICE" />
    </http>

    <http auto-config="true">
        <port-mappings>
            <port-mapping http="8009" https="8443"/>
            <port-mapping http="80" https="443"/>
        </port-mappings>
        <intercept-url pattern="/index.*" access="ROLE_USER" />
        <intercept-url pattern="/welcome.htm" access="ROLE_USER" />
        <intercept-url pattern="/changePassword.htm" access="ROLE_USER" />
        <intercept-url pattern="/admin/**" access="ROLE_USER" />
        <intercept-url pattern="/notifications/**" access="ROLE_ANONYMOUS,ROLE_USER" />
        <intercept-url pattern="/logging/**" access="ROLE_USER" />
        <form-login login-page="/login.htm" default-target-url="/welcome.htm"
            authentication-failure-url="/loginfailed.htm" />
        <logout logout-success-url="/logout.htm" />
    </http>


您的apache、tomcat和负载平衡器配置是这里的重要信息。如果您使用的是反向代理,我根本不会使用SpringSecurity的端口映射。您应该能够让它在Tomcat和Apache配置之间工作。你需要花一些时间看看浏览器请求是如何处理的,尤其是重定向是如何重写的。它通过https发送到spring_security_check,然后执行301重定向到http登录页。我是说302重定向