Configuration
Redirect feature configuration
Properties
The hosts a request may be redirected to when host is not set: ASCII host names, IPv4 addresses or bracketed IPv6 literals, with no port. A request whose host (compared case-insensitively, ignoring a trailing dot) is not listed gets 400 Bad Request; one that is listed is redirected to its own host. Defaults to empty, which allows any valid request host. Ignored when host is set.
The list of call predicates for redirect exclusion. Any call matching any of the predicates will not be redirected by this feature.
HTTPS host to redirect to: an ASCII host name, an IPv4 address or a bracketed IPv6 literal. Set the port with sslPort; a :port (1 to 65535) appended to the host is still accepted for compatibility, and is then used as given, so leave sslPort at its default when doing that. Defaults to null, which keeps the host of the incoming request, call.request.origin.serverHost: the client's Host header, or its X-Forwarded-Host, X-Forwarded-Server or Forwarded: host= value when Ktor's XForwardedHeaders or ForwardedHeaders plugin is installed. A router that routes on Host, such as Heroku's, does not check those headers, so always set it, or, for an application that serves several domains, set allowedHosts.
Use permanent redirect or temporary
Functions
Exclude calls matching the predicate from being redirected to https by this feature. The predicate gets the call as the engine built it: on Ktor CIO, call.request.path() of an absolute-form request target (GET http://host/path) still holds the scheme and authority, unlike the path excludePrefix and excludeSuffix match.
Exclude calls whose path (not including the query string) starts with pathPrefix from being redirected to https by this feature. The path of an absolute-form request target (GET http://host/health) is its own path (/health), so such a call is excluded exactly when the origin-form request would be.
Exclude calls whose path (not including the query string) ends with pathSuffix from being redirected to https by this feature. The path of an absolute-form request target (GET http://host/robots.txt) is its own path (/robots.txt), so such a call is excluded exactly when the origin-form request would be.