Last active
September 6, 2019 23:13
-
-
Save juanlugm/21c0e942433b7736f9ab32aad1efc3d3 to your computer and use it in GitHub Desktop.
HTTPS - Spring Boot 2 - Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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