6.29.5 Enabling HTTP and HTTPS

Micronaut supports binding both HTTP and HTTPS. To enable dual protocol support, modify your configuration. For example with application.yml:

Dual Protocol Configuration Example

  1. micronaut:
  2. ssl:
  3. enabled: true
  4. build-self-signed: true (1)
  5. server:
  6. dual-protocol : true (2)
1You must configure SSL for HTTPS to work. In this example we are just using a self-signed certificate, but see Securing the Server with HTTPS for other configurations
2Enabling both HTTP and HTTPS is an opt-in feature - setting the dualProtocol flag enables it. By default Micronaut only enables one

It is also possible to redirect automatically all HTTP request to HTTPS. Besides the previous configuration, you need to enable this option. For example, with application.yml:

Enable HTTP to HTTPS Redirects

  1. micronaut:
  2. ssl:
  3. enabled: true
  4. build-self-signed: true
  5. server:
  6. dual-protocol : true
  7. http-to-https-redirect: true (1)
1Enable HTTP to HTTPS redirects