[英]Disable spring security https redirecting
我正在使用Web应用程序,并将ssl证书配置为在Tomcat中的https上运行。
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" clientAuth="false" keystoreFile="conf/expchannel.pfx" keystorePass="***" keystoreType="PKCS12">
由于某些原因,客户端希望在8080端口上运行它。 应该没关系。
问题出在Spring安全性登录拦截器上。 收到请求后,它将自动重定向到登录页面,但由于未知原因,它使用8443端口,该端口将永远不会提供服务(以超时结束)
组态:
<security:http auto-config="true" use-expressions="true">
<security:csrf disabled="true"/>
<!-- Other pages only autenticated -->
<security:intercept-url pattern="/pages/userManagement.xhtml" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/pages/performanceMonitoring.xhtml" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/pages/**" access="hasRole('ROLE_USER')" />
<security:session-management invalid-session-url="/sessionExpired.xhtml">
</security:session-management>
<!-- Set the login page and what to do if login fails -->
<security:form-login login-page="/login.xhtml" authentication-failure-url="/loginFail.xhtml"
default-target-url="/pages/statusOverview.xhtml" />
<security:csrf/>
</security:http>
在7080端口上运行的其他应用程序实例不存在此问题,我猜想有某种隐藏的默认行为,可以在https请求的情况下将端口从8080-> 8443准确地更改。
有没有办法禁用此行为? 我在寻找答案,但没有找到任何答案。 我发现的唯一解决方案是在spring配置中显式设置http和https端口,这对我来说似乎不合适。 我希望它可以在tomcat配置上进行配置,而不是针对每个Web应用程序进行单独配置。
谢谢你的帮助。
您需要在该连接器上设置secure="true"
以及scheme="https"
。
请注意,将端口8080
用于安全HTTP就像将端口80
用于纯文本HTTP: Surprise 。
值8443
来自Tomcat在连接器上的默认redirectPort
设置:Tomcat(或可能是Spring)将用户重定向到它认为是“安全”的连接器,因为所有登录都应通过TLS执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.