Spring boot - 将 Tomcat HTTP 嵌入到 HTTPS 重定向 [英] Spring boot - Embeded Tomcat HTTP to HTTPS redirect

查看:51
本文介绍了Spring boot - 将 Tomcat HTTP 嵌入到 HTTPS 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Java 7、Spring-Boot 1.1.7 和嵌入式 Tomcat 7.

I'm using Java 7, Spring-Boot 1.1.7 and an ambeded Tomcat 7.

过去,当我使用独立的 Tomcat 时,我曾经添加一个 http 连接器,它将请求重定向到 HTTPS 端口:

In the past, when I used a stand alone Tomcat, I used to add an http connector, that will redirect the requests to the HTTPS port :

<Connector port="8080" enableLookups="false"
           redirectPort="8443" />

当我使用嵌入式 Tomcat(并且我没有 server.xml 文件)时,我该怎么做?

How can I do it when I'm using an embeded Tomcat (and I dont have a server.xml file) ?

推荐答案

您可以添加 Connector 或使用其 Java API 配置现有的连接器(例如,请参阅 http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat).Connector 有一个 setRedirectPort()(它由 XML <Connector/> 元素直接映射).

You can add a Connector or configure the existing one with its Java API (e.g. see http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat). The Connector has a setRedirectPort() (it's mapped directly by the XML <Connector/> element).

这篇关于Spring boot - 将 Tomcat HTTP 嵌入到 HTTPS 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆