To configure HTTP and HTTPS in Spring Boot,
add the following properties in application.properties:
http.port=80
server.port=443
server.ssl.key-store=/home/izeye/keystore
server.ssl.key-store-password=keystore
server.ssl.key-password=privatekey
and add an embedded servlet container customer as follows:
@Configuration
public class TomcatConfig {
    @Value("${http.port}")
    private int httpPort;
    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                if (container instanceof TomcatEmbeddedServletContainerFactory) {
                    TomcatEmbeddedServletContainerFactory containerFactory =
                            (TomcatEmbeddedServletContainerFactory) container;
                    Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
                    connector.setPort(httpPort);
                    containerFactory.addAdditionalTomcatConnectors(connector);
                }
            }
        };
    }
}
Reference:
http://izeye.blogspot.kr/2015/01/configure-https-with-self-signed.html
Thanks
ReplyDeleteyou should need surely to start your application with root access under linux
ReplyDeleteThis comment has been removed by the author.
ReplyDelete