Java 为什么端口80在https中添加了Spring安全性?
登录时,我的应用程序将从443重定向到80: 原始URL是 但是当我提交URL https://myhost.com/myapp/j_spring\u security\u check时,如果登录成功,请尝试连接到https://myhost.com:80/myapp/ URL https://myhost.com/myapp/login.jsp调用apache服务器。 这个apache使用http(端口11080)调用tomcat 登录操作由Spring Security处理,配置如下:Java 为什么端口80在https中添加了Spring安全性?,java,tomcat,spring-security,Java,Tomcat,Spring Security,登录时,我的应用程序将从443重定向到80: 原始URL是 但是当我提交URL https://myhost.com/myapp/j_spring\u security\u check时,如果登录成功,请尝试连接到https://myhost.com:80/myapp/ URL https://myhost.com/myapp/login.jsp调用apache服务器。 这个apache使用http(端口11080)调用tomcat 登录操作由Spring Security处理,配置如下: &l
<?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>
这几乎是我的问题,除了我不是用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" />
问题似乎在于指令响应。sendRedirect在Spring security中用于登录,在我的应用程序中用于注销:
response.sendRedirect(response.encodeRedirectURL(finalUrl));
为了解决这个问题,我在tomcat中添加了一个valve,如本文所述:公认的答案是建议使用一个依赖于Microsoft特定头的自定义valve(前端Https)。相反,您应该使用已经提供的,并且依赖事实上的标准x-forwarded-proto头
AJP代理无需额外努力即可工作的原因是它是一个二进制协议,因此web服务器/负载平衡器和Tomcat之间没有HTTP调用,因此没有架构/端口更改问题。请发布您的Tomcat连接器配置。内部服务器配置(用于重定向)可能有问题。事实上,当你使用AJP时,它会起作用,这使得这种情况更可能发生。