我在AWS EC2实例上的端口8080上运行Spring引导(Jhipster/Undertow)应用程序。带有嵌入式Undertow的AWS Boot ELB - HTTPS重定向
我有一个AWS ELB配置为重定向
80 -> 8080
443 (SSL termination happens here) -> 8080
该应用程序使用的Spring Security,如果你的用户到达http://example.com我希望它重定向到https://example.com,使用SSL。
我发现了在Tomcat中配置这个的各种示例,但没有使用Undertow。
我已经尝试过,第二个端口8089,它根据需要重定向,但这会导致端口8080也重定向,我不想要。
80 -> 8089
443 (SSL termination happens here) -> 8080
@Bean
public EmbeddedServletContainerFactory undertow() {
UndertowEmbeddedServletContainerFactory undertow = new UndertowEmbeddedServletContainerFactory();
undertow.addBuilderCustomizers(builder -> builder.addHttpListener(8089, "0.0.0.0"));
undertow.addDeploymentInfoCustomizers(deploymentInfo -> {
deploymentInfo.addSecurityConstraint(new SecurityConstraint()
.addWebResourceCollection(new WebResourceCollection()
.addUrlPattern("/*"))
.setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
.setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT))
.setConfidentialPortManager(exchange -> 443);
});
return undertow;
}
如何配置Undertow来实现此目的?
https://twitter.com/ankinson/status/829256167700492288可能涉及类似的问题,你想解决? –