Skip to content

Proposal: Introduce host_rewrite_path support in route config #12430

@Pchelolo

Description

@Pchelolo

Rational

Using subdomains for tenant-id in a multi-tenant application is a relatively popular strategy, our own MediaWiki (the software behind Wikipedia) uses Host header to distinguish between different language wikis. Ability to rewrite Host based on path would provide flexibility in moving the tenant-id from subdomain to path when deploying existing software behind the proxy.

Proposal

Introduce a new host_rewrite_path option in RouteAction:host_rewrite_specifier.

// Indicates that during forwarding, the host header will be swapped with the result of the
// given regex substitution run agains the request path. 
type.matcher.v3.RegexMatchAndSubstitute host_rewrite_path = 36;

The behavior of the new property would be the following: Host header will be set to the result of the RegexMatchAndSubstitute, executed agains the path. However, this would need to be applied with care, since the regex matcher needs to be guaranteed to match the whole path string. Alternatively, a new RegexMatchAndReplace message could introduced, where the result would replace the input string with capture groups applied, or null if the regex did not match the input - in that case the host header would not be swapped if the regex did not match.

We are going to provide implementation and testing. Seeking approval from the maintainers and guidance on whether to reuse RegexMatchAndSubstitute or introduce a new message type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions