Spring boot - Embeded Tomcat HTTP to HTTPS redirect

梦想的初衷 提交于 2019-12-11 12:36:08

问题


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

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" />

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


回答1:


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).



来源:https://stackoverflow.com/questions/26438143/spring-boot-embeded-tomcat-http-to-https-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!