s5b*_*s5b 3 https spring jetty amazon-web-services
我正在AWS中运行Spring Boot应用程序.应用程序在Elastic Load Balancer(ELB)后面运行.ELB配置为使用https(端口443)到外部世界,但通过http(端口8080)到应用程序.ELB配置为通过x-forwarded-proto标头.我正在使用Jetty 9.0.0.M0,使用Spring Boot 1.1.5 RELEASE.
我似乎是通过ELB从应用程序发回的错误重定向,其中重定向响应将返回http,而不是https.现在,我在这里读到我应该将"转发"标题设置为true使用:
<Set name="forwarded">true</Set>
Run Code Online (Sandbox Code Playgroud)
我无法看到如何使用Spring Boot中的嵌入式Jetty版本来执行此操作,因为我的源代码中没有XML配置文件.
我已经查看了EmbeddedServletContainerCustomizer基础设施,但我仍然无法获得正确的咒语来使这个设置工作.
该应用程序是在AWS https环境之外构建和测试的,因此应用程序也需要透明地工作http.直接命中应用程序端点而无需通过ELB工作.只是ELB到申请路线不起作用.
有任何想法吗?
我自己有一个类似的问题,而研究时遇到了你的问题.我发现这很容易以编程方式进行,但是在Jetty文档中并没有真正解释过.
Jetty xml配置文件的结构与java API的结构相匹配,因此您可以在代码中复制它.
那么下面就如何使用XML配置文件来配置Jetty的指导这里
我能够以编程方式配置嵌入式服务器,如下所示:
Server server = new Server( port );
// Create HTTP Config
HttpConfiguration httpConfig = new HttpConfiguration();
// Add support for X-Forwarded headers
httpConfig.addCustomizer( new org.eclipse.jetty.server.ForwardedRequestCustomizer() );
// Create the http connector
HttpConnectionFactory connectionFactory = new HttpConnectionFactory( httpConfig );
ServerConnector connector = new ServerConnector(server, connectionFactory);
// Make sure you set the port on the connector, the port in the Server constructor is overridden by the new connector
connector.setPort( port );
// Add the connector to the server
server.setConnectors( new ServerConnector[] { connector } );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4594 次 |
| 最近记录: |