ber*_*mme 0 iptables tomcat8 spring-boot
我使用 spring boot(嵌入 tomcat)和 ssl。
实际上,我需要在 url 中输入端口 (8443) 才能访问 Web 应用程序。
如何才能仅使用域名?
代替
编辑
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat
= new TomcatEmbeddedServletContainerFactory() {
@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(createHttpConnector());
return tomcat;
}
private Connector createHttpConnector() {
Connector connector
= new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setSecure(false);
connector.setPort(8080);
connector.setRedirectPort(8443);
return connector;
}
Run Code Online (Sandbox Code Playgroud)
现在不需要输入端口
但如果输入 bob.com,浏览器会转换为
鲍勃.com:8443
浏览器用于 HTTP 的默认端口是 80,HTTPS 是 443。如果您在 443 上运行应用程序(因为您使用的是 HTTPS),则不必使用端口号,浏览器将自动重新路由您的 URL。要更改 spring-boot 应用程序中的端口号,请server.port在 bootstrap.yml 中指定属性。
server:
port: 443
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1626 次 |
| 最近记录: |