diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 935f879..7720153 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -1,8 +1,14 @@ package com.ruoyi; +import org.apache.catalina.Context; +import org.apache.catalina.connector.Connector; +import org.apache.tomcat.util.descriptor.web.SecurityCollection; +import org.apache.tomcat.util.descriptor.web.SecurityConstraint; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.context.annotation.Bean; /** * 启动程序 @@ -17,4 +23,34 @@ public class RuoYiApplication SpringApplication.run(RuoYiApplication.class, args); System.out.println("(♥◠‿◠)ノ゙ ---tongue---启动成功 ლ(´ڡ`ლ)゙ "); } + + + @Bean + public TomcatServletWebServerFactory servletContainer() { //springboot2 新变化 + + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() { + + @Override + protected void postProcessContext(Context context) { + + SecurityConstraint securityConstraint = new SecurityConstraint(); + securityConstraint.setUserConstraint("CONFIDENTIAL"); + SecurityCollection collection = new SecurityCollection(); + collection.addPattern("/*"); + securityConstraint.addCollection(collection); + context.addConstraint(securityConstraint); + } + }; + tomcat.addAdditionalTomcatConnectors(initiateHttpConnector()); + return tomcat; + } + + private Connector initiateHttpConnector() { + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setScheme("http"); + connector.setPort(8888); + connector.setSecure(false); + connector.setRedirectPort(9080); + return connector; + } } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index fa24ed4..881a0f4 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -18,7 +18,9 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8091 + port: 9080 + http: + port: 8888 servlet: # 应用的访问路径 context-path: / @@ -32,6 +34,9 @@ server: max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 + ssl: + key-store: tongue.nanjingyinuo.com.jks + key-store-password: 123456 # 日志配置 logging: diff --git a/ruoyi-admin/src/main/resources/tongue.nanjingyinuo.com.jks b/ruoyi-admin/src/main/resources/tongue.nanjingyinuo.com.jks new file mode 100644 index 0000000..b63883d Binary files /dev/null and b/ruoyi-admin/src/main/resources/tongue.nanjingyinuo.com.jks differ