添加https支持

This commit is contained in:
zhh
2018-08-06 17:02:43 +08:00
parent 575eb0a8f8
commit 69ec434f43
4 changed files with 33 additions and 5 deletions

BIN
keystore.p12 Normal file

Binary file not shown.

View File

@@ -1,14 +1,35 @@
package com.macro.mall.portal; package com.macro.mall.portal;
import org.apache.catalina.connector.Connector;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication
@MapperScan({"com.macro.mall.mapper","com.macro.mall.portal.dao"}) @MapperScan({"com.macro.mall.mapper","com.macro.mall.portal.dao"})
public class MallPortalApplication { public class MallPortalApplication {
@Value("${http.port}")
private Integer port;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MallPortalApplication.class, args); SpringApplication.run(MallPortalApplication.class, args);
} }
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
return tomcat;
}
//配置http
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
return connector;
}
} }

View File

@@ -62,10 +62,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.logoutSuccessHandler(new GoLogoutSuccessHandler()) .logoutSuccessHandler(new GoLogoutSuccessHandler())
.invalidateHttpSession(true) .invalidateHttpSession(true)
.deleteCookies("JSESSIONID") .deleteCookies("JSESSIONID")
// .and() .and()
// .requiresChannel() .requiresChannel()
// .antMatchers("/sso/*").requiresSecure() .antMatchers("/sso/*")
// .anyRequest().requiresInsecure() .requiresSecure()
.anyRequest()
.requiresInsecure()
// .and() // .and()
// .rememberMe() // .rememberMe()
// .tokenValiditySeconds(1800) // .tokenValiditySeconds(1800)

View File

@@ -1,5 +1,10 @@
#===server start=== #===server start===
server.port=8085 http.port=8085
server.port=8443
server.ssl.key-store=keystore.p12
server.ssl.key-alias=tomcat
server.ssl.key-store-password=123456
server.ssl.key-store-type=PKCS12
#===server end=== #===server end===
#===logging start=== #===logging start===