Overriding Host Header not working

The way we do it is: (this only works as of 2.5.2+)

a) Create a custom JSVM pre-middleware plugin that analyzes anything you want from the current request (Host, path, url etc)

b) In that plugin, set any number of custom http request headers based off what you analyze (i.e. the new target url to proxy to, the original fqdn host requested…whatever you want)

c) then via an URL rewriter do something like

                    "url_rewrites": [
                        {
                            "path": "/.*",
                            "method": "POST",
                            "match_pattern": "/.*",
                            "rewrite_to": "$tyk_context.headers_X_My_Customproxytourl",
                            "triggers": []
                        }
                    ],

The endpoint you are proxying to, would be able to see all the headers you set in your jsvm plugin as well