6.5 Host Resolution

You may need to resolve the host name of the current server. Micronaut ships with an implementation of the HttpHostResolver interface.

The default implementation will look for host information in the following places in order:

  1. The supplied configuration

  2. The Forwarded header

  3. The X-Forwarded- headers. If the X-Forwarded-Host header is not present, the other X-Forwarded headers are ignored.

  4. The Host header

  5. The properties on the request URI

  6. The properties on the embedded server URI

The behavior of which headers to pull the relevant data can be changed with the following configuration:

🔗

Table 1. Configuration Properties for HttpServerConfiguration$HostResolutionConfiguration
PropertyTypeDescription

micronaut.server.host-resolution.host-header

java.lang.String

The header name that stores the host

micronaut.server.host-resolution.protocol-header

java.lang.String

The header name that stores the protocol

micronaut.server.host-resolution.port-header

java.lang.String

The header name that stores the port

micronaut.server.host-resolution.port-in-host

boolean

True if the host header supports a port