后端服务器如何映射https

主机教程 建站分享 2年前 (2022-10-30) 193次浏览

文章摘要:后端服务器如何映射https

在后端服务器中设置映射https,具体方法如下: public class Http2HttpsConfig […]

在后端服务器中设置映射https,具体方法如下:

public class Http2HttpsConfig {

/**

* 配置服务器容器

*/

@Bean

public EmbeddedServletContainerFactory servletContainer(){

TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(){

@Override

protected void postProcessContext(Context context) {

SecurityConstraint securityConstraint = new SecurityConstraint();

securityConstraint.setUserConstraint("CONFIDENTIAL");

SecurityCollection securityCollection = new SecurityCollection();

securityCollection.addPattern("/*");

securityConstraint.addCollection(securityCollection);

context.addConstraint(securityConstraint);

}

};

tomcat.addAdditionalTomcatConnectors(httpConnector());

return tomcat;

}

/**

* 设置http到https的url映射

*/

@Bean

public Connector httpConnector(){

Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");

connector.setScheme("http");

connector.setPort(8080);

connector.setSecure(false);

connector.setRedirectPort(8088);

return connector;

}

}


声明:
若非注明,本站文章源于互联网收集整理和网友分享发布,如有侵权,请联系站长处理。
文章名称:后端服务器如何映射https
文章链接:http://www.7966.org/post/13934.html
转载请注明出处

喜欢 (0)