我在Web应用程序中使用Spring Secutiry框架。我已经安装了SSL证书,并且能够通过https
访问我的应用程序。
现在,当我向所有requires-channel="https"
指令添加intercept-url
属性时,服务器响应:
Error 310 (net::ERR_TOO_MANY_REDIRECTS) to many connections
Spring每次运行此代码:
64050 [http-bio-8080-exec-1] DEBUG org.springframework.security.web.FilterChainProxy - / at position 1 of 12 in additional filter chain; firing Filter: 'ChannelProcessingFilter'
64050 [http-bio-8080-exec-1] DEBUG org.springframework.security.web.util.AntPathRequestMatcher - Checking match of request : '/'; against '/'
64050 [http-bio-8080-exec-1] DEBUG org.springframework.security.web.access.channel.ChannelProcessingFilter - Request: FilterInvocation: URL: /; ConfigAttributes: [REQUIRES_SECURE_CHANNEL]
64050 [http-bio-8080-exec-1] DEBUG org.springframework.security.web.access.channel.RetryWithHttpsEntryPoint - Redirecting to: https://sky-handling.ejl-group.com/
64050 [http-bio-8080-exec-1] DEBUG org.springframework.security.web.DefaultRedirectStrategy - Redirecting to 'https://sub.domain.com/'
我该如何解决?
谢谢
UPD#1:
<http use-expressions="true">
<form-login login-page="/wellcome/" login-processing-url="/login" default-target-url="/" always-use-default-target="false"
authentication-failure-url="/wellcome/?error=1" username-parameter="email" password-parameter="password" />
<remember-me key="temp" token-validity-seconds="-1" />
<logout invalidate-session="true" logout-success-url="/" logout-url="/logout"/>
<intercept-url pattern="/" access="authenticated"/>
<intercept-url pattern="/administration/**" access="authenticated"/>
<intercept-url pattern="/wellcome/" access="permitAll"/>
<intercept-url pattern="/login" access="permitAll"/>
<custom-filter ref="ajaxTimeoutRedirectFilter" after="EXCEPTION_TRANSLATION_FILTER"/>
</http>
我将现有证书导入密钥库并配置了tomcat,但是如果我添加这样的行:
<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile /usr/local/ssl/crt/public.crt
SSLCertificateKeyFile /usr/local/ssl/private/*.ejl-group.com.key
SSLCACertificateFile /usr/local/ssl/crt/intermediate.crt
ServerName sub.domain.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8443/
ProxyPassReverse / http://localhost:8443/
</VirtualHost>
失败并显示503 Service Temporarily Unavailable
错误
答案 0 :(得分:5)
我通过在security.xml文件中添加端口映射来修复此问题:
<http>
<port-mappings>
<port-mapping http="8088" https="8443"/>
<port-mapping http="80" https="443"/>
</port-mappings>
</http>
如果您支持负载均衡器,则必须添加一些代码:Offloading https to load balancers with Spring Security
答案 1 :(得分:1)
我认为这两行是关键:
ProxyPass / http://localhost:8443/
ProxyPassReverse / http://localhost:8443/
请注意,您在此处指定http,而不是https。所以发生的事情是,当客户端通过默认HTTPS端口(443)访问您的网站时,httpd使用http方案将请求转发给tomcat实例。然后,tomcat尝试重定向到HTTPS / 443端口,然后httpd通过使用http方案将请求转发给tomcat实例,依此类推。
如果你只是将sceme改为https,我不确定它是否会起作用,但试一试。
虽然我不了解您的安全要求,但通常没有必要在httpd前端和tomcat后端之间建立SSL加密链接。考虑在这里使用简单的HTTP,或者甚至可以使用AJP