Hostname Rewrite from Middlewares

Hello,

I’m wondering if it is possible to set the URL Rewrite for the downstream host from the middleware? Specifically, coprocess GRPC middleware.

We have a pretty hacky solution right now, where our middleware sets a session metadata token like so:

Session.Metadata = "{new_host: someotherhost.com}"

And then our URL rewrite config uses tyk contexts:

“url_rewrites”: [{
“path”: “/”,
“method”: “GET”,
“match_pattern”: “”,
“rewrite_to”: “http://$tyk_meta.new_host”
}]

But we think there should be a simpler solution to override host from plugins.

1 Like