标签:image factor 监听端口 ssl 研究 跳转 factory png mbed
首先需要去做个证书
yml配置文件中设置的是https监听端口
server:
port: 10007
tomcat:
basedir: /data/apps/temp
#配置SSL
ssl:
key-store: classpath:bdcourtyard.com.jks
key-store-password: 4a98pp121wv
keyStoreType: JKS
以下是启动类添加的代码
/** * it‘s for set http url auto change to https */ @Bean public TomcatEmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() { @Override protected void postProcessContext(Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setUserConstraint("CONFIDENTIAL");//confidential SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); } }; tomcat.addAdditionalTomcatConnectors(httpConnector()); return tomcat; } @Bean public Connector httpConnector() { Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setScheme("http"); connector.setPort(9000); connector.setSecure(true); connector.setRedirectPort(10007); return connector; }
这个是同事配的,实测有效搬过来具体自己还没研究
spring boot之支持http和https并行(http不跳转)
标签:image factor 监听端口 ssl 研究 跳转 factory png mbed
原文地址:https://www.cnblogs.com/heroinss/p/10509739.html