【发布时间】:2018-06-07 12:11:40
【问题描述】:
我已经通过 Elastic Beanstalk 部署了一个 Spring Boot 应用程序。我正在使用负载均衡器,所以这是流程(据我所知):
Internet/浏览器请求---HTTPS--->负载均衡器---HTTP---> Spring Boot App Server
因此,从本质上讲,SSL 终止于负载均衡器,而应用服务器只处理普通的旧 HTTP。
但是对于来自浏览器的 HTTP 请求,我希望负载均衡器自动重定向到 HTTPS。
关于这个问题有几个问题:
Spring Boot with Embedded Tomcat behind AWS ELB - HTTPS redirect
How to redirect automatically to https with Spring Boot
Spring Boot redirect HTTP to HTTPS
但是这些问题的答案对我来说没有任何意义。也许我理解错了,但所有的答案基本上都使 Spring Boot 应用程序仅服务器 HTTPS 请求(例如使用http.requiresChannel().anyRequest().requiresSecure() 时)。
但是,这与流程背道而驰,因为 SSL 在负载均衡器处终止,而 Spring Boot 应用程序服务器只处理 HTTP,我对此非常满意。因此,如果我在 Spring Boot 级别需要 SSL,那么我需要进行端到端 SSL 连接,这对于我的应用程序来说并不是真正需要的。
我还使用了以下属性,但似乎也无济于事:
server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.protocol-header=x-forwarded-proto
【问题讨论】:
标签: spring amazon-web-services spring-boot amazon-elastic-beanstalk