Spring Boot重定向到https

问题描述 投票:0回答:1

我使用centos 7,春季靴(使用嵌入式tomcat的人]

在我的application.properties中

security.require-ssl=true
server.port: 8443

我可以通过]访问我的网站>

www.xxxx.com

但是

xxxx.com

不工作

我也尝试过

在我的application.properties中

server.port: 8443

在应用程序类中

@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;
}

我在日志中看到

s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8443 (https) 8080 (http)

www.xxxxx.com正在运行

xxxx.com将自动转换为

xxxx.com:8443

我不明白为什么要添加端口。

我使用centos 7,春季启动(谁使用嵌入式tomcat)在我的application.properties security.require-ssl = true server.port:8443我可以通过www.xxxx.com访问我的网站,但是xxxx.com却不可以t ...

tomcat ssl browser spring-boot centos
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.