Spring Boot 重定向 HTTP 到 HTTPS
2022-08-31 22:42:28
对于基于Spring Boot的应用程序,我在appplicatial.properties上配置了ssl属性,请参阅此处的配置:
server.port=8443
server.ssl.key-alias=tomcat
server.ssl.key-password=123456
server.ssl.key-store=classpath:key.p12
server.ssl.key-store-provider=SunJSSE
server.ssl.key-store-type=pkcs12
我在应用程序上添加了连接.class,例如
@Bean
public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
final TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addAdditionalTomcatConnectors(this.createConnection());
return factory;
}
private Connector createConnection() {
final String protocol = "org.apache.coyote.http11.Http11NioProtocol";
final Connector connector = new Connector(protocol);
connector.setScheme("http");
connector.setPort(9090);
connector.setRedirectPort(8443);
return connector;
}
但是当我尝试以下
http://127.0.0.1:9090/
重定向至
https://127.0.0.1:8443/
不执行。谁面临类似的问题?