at.*_*at. 6 https jsp load-balancing spring-mvc spring-security
现在,负载均衡器处理https,然后将该https传递给我的Web服务器.因此,为每个请求处理https double.我想要做的是完全卸载https所以我的网络服务器不必处理它.
如果Web服务器认为所有请求都是http,我如何配置Spring Security和JSP页面?显然,我必须修改<intercept-url>配置的元素,使其requires-channel属性始终为http或any.在我的JSP页面中,我必须在<c:url value=''/>链接前加上a ${secureUrl}并${nonSecureUrl}依赖于结果页面是否需要是https或http.控制器的重定向也需要像这样修改......还有别的吗?
修改JSP页面中的所有链接以包含方案和主机似乎非常痛苦.有没有更好的方法呢?
如果您在负载均衡器处终止SSL,则负载均衡器应发送一个标头,指示最初请求的协议.例如,F5添加了X-Forwarded-Proto.
从这里你可以创建自定义ChannelProcessors来查看此标题而不是查看request.isSecure().然后你可以继续使用<intercept-url requires-channel="https">和亲戚<c:url>.
步骤:
子类SecureChannelProcessor和InsecureChannelProcessor重写decide().在decide()检查头通过负载平衡器发送.
@Override
public void decide(FilterInvocation invocation, Collection<ConfigAttribute> config) throws IOException, ServletException {
for (ConfigAttribute attribute : config) {
if (supports(attribute)) {
if (invocation.getHttpRequest().
getHeader("X-Forwarded-Proto").equals("http")) {
entryPoint.commence(invocation.getRequest(),
invocation.getResponse());
}
}
}
}
Run Code Online (Sandbox Code Playgroud)然后使用a 在ChannelDecisionManagerImpl bean 上设置这些ChannelProcessors BeanPostProcessor.有关为何/如何使用此问题,请参阅此Spring Security常见问题解答BeanPostProcessor.
| 归档时间: |
|
| 查看次数: |
6132 次 |
| 最近记录: |