How set up Spring Boot to run HTTPS / HTTP ports

后端 未结 6 659
半阙折子戏
半阙折子戏 2020-12-12 23:58

Spring boot have some properties to config web port and SSL settings, but once a SSL certificate is set the http port turns into https port.

So, how can I keep both

6条回答
  •  既然无缘
    2020-12-13 00:28

    Take a look at: https://github.com/creactiviti/spring-boot-starter-acme. It makes it very easy to auto-generate a LetsEncrypt based SSL certificate.

    From the README:

    1. Add the module to your pom.xml file as a dependency.

    2. Build your project.

    3. Deploy it to a target machine and point your domain name to the IP address of that machine. LetsEncrypt validates your ownership of the domain by making a callback to the http://your-domain/.well-known/acme-challenge/{token} endpoint exposed by this module.

    4. Make sure that your server has openssl available on its $PATH.

    5. To activate spring-boot-starter-acme and generate a certificate execute:

      sudo java -Dserver.port=80 -Dacme.enabled=true -Dacme.domain-name= -Dacme.accept-terms-of-service=true -jar mysecureapp-0.0.1-SNAPSHOT.jar

    6. Check your console for a confirmation that the certificate was successfully generated.

    7. Stop your application and configure it to make use of the generated certificate:

      server.port=443 server.ssl.key-store=keystore.p12 server.ssl.key-store-password=password server.ssl.keyStoreType=PKCS12

提交回复
热议问题