6.6 Host Resolution
You may need to resolve the host name of the current server. Micronaut includes an implementation of the HttpHostResolver interface.
The default implementation looks for host information in the following places in order:
The supplied configuration
The
Forwarded
headerX-Forwarded-
headers. If theX-Forwarded-Host
header is not present, the otherX-Forwarded
headers are ignored.The
Host
headerThe properties on the request URI
The properties on the embedded server URI
The behavior of which headers to pull the relevant data can be changed with the following configuration:
Property | Type | Description |
---|---|---|
| The host resolution configuration | |
| java.lang.String | The header name that stores the host |
| java.lang.String | The header name that stores the protocol |
| java.lang.String | The header name that stores the port |
| boolean | True if the host header supports a port |
| java.util.List | The list of allowed host regex patterns. Any resolved |
The above configuration also supports an allowed host list. Configuring this list ensures any resolved host matches one of the supplied regular expression patterns. That is useful to prevent host cache poisoning attacks and is recommended to be configured.