Skip to content

Instantly share code, notes, and snippets.

@juanlugm
Last active September 6, 2019 23:13
Show Gist options
  • Save juanlugm/21c0e942433b7736f9ab32aad1efc3d3 to your computer and use it in GitHub Desktop.
Save juanlugm/21c0e942433b7736f9ab32aad1efc3d3 to your computer and use it in GitHub Desktop.
HTTPS - Spring Boot 2 - Nginx
#Keystore type
server.ssl.key-store-type: PKCS12
#Path to the keystore
server.ssl.key-store: /etc/letsencrypt/live/mydomain.com/keystore.p12
#Keystore password
server.ssl.key-store-password: YourKeyStorePassword
#Alias mapped to the certificate
server.ssl.key-alias: mydomainkeyalias
#Spring Boot on HTTPS only
server.port: 8443
#HTTP port
http.port: 8080
@Configuration
public class HTTPSConfiguration {
//HTTP port
@Value("${http.port}")
private int httpPort;
// Let's configure additional connector to enable support for both HTTP and HTTPS
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(httpPort);
return connector;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment