【发布时间】:2012-02-07 02:42:26
【问题描述】:
登录时,我的应用程序从 443 重定向到 80 : 原始网址是https://myhost.com/myapp/login.jsp 但是当我提交 URL https://myhost.com/myapp/j_spring_security_check 时,登录成功,尝试连接到 https://myhost.com:80强>/myapp/
URL https://myhost.com/myapp/login.jsp 调用 apache 服务器。 这个 apache 使用 http(端口 11080)调用了一个 tomcat。
登录操作由具有该配置的 Spring Security 处理:
<?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>
这个问题只存在于登录和注销操作,所以我认为 Spring Security 是问题所在。
一切正常,当原始 URL 不使用默认 https 端口 443 时没有重定向:https://myhost.com:12345/myapp/login.jsp
当 apache 使用协议 ajp 调用 Tomcat 时,一切正常。
不幸的是,我必须在端口 443 上调用 apache,并使用协议 http 调用 Tomcat。
线程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" />
【问题讨论】:
-
请发布您的 tomcat 连接器配置。内部服务器配置(用于重定向)可能存在问题。当您使用 AJP 时它会起作用,这一事实使这种情况更有可能发生。
标签: java tomcat spring-security