I have the same question as this question but not in an EC2 context, just simply starting my spring boot application from the command line. I managed to get my application running with HTTPS by following the code from this example:
@Profile( "security" )
@Configuration
public class SecurityConfiguration
{
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer( @Value("${keystore.file}") Resource keystoreFile,
@Value("${keystore.pass}") final String keystorePass ) throws IOException
{
final String absoluteKeystoreFile = keystoreFile.getFile().getAbsolutePath();
return new EmbeddedServletContainerCustomizer()
{
@Override
public void customize( ConfigurableEmbeddedServletContainer container )
{
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory)container;
tomcat.addConnectorCustomizers( new TomcatConnectorCustomizer()
{
@Override
public void customize( Connector connector )
{
connector.setPort( 8443 );
connector.setSecure( true );
connector.setScheme( "https" );
Http11NioProtocol proto = (Http11NioProtocol)connector.getProtocolHandler();
proto.setSSLEnabled( true );
proto.setKeystoreFile( absoluteKeystoreFile );
proto.setKeystorePass( keystorePass );
proto.setKeystoreType( "PKCS12" );
proto.setKeyAlias( "tomcat" );
}
} );
}
};
}
}
So now I can access my application on https://localhost:8443/
.
I would like that http://localhost:8443
would redirect to https. Now Chrome just shows: "No data received" which is not very user friendly.