I'm helping a CommandBox user convert some Tuckey rewrite filter rules to Undertow's predicate language. Here is the Tucky example they provided me:
<rule>
<from>^/test/(.*)</from>
<to last="true" type="proxy">http://test.com/$1</to>
</rule>
My first thought was just to use the reverse-proxy() handler, but upon further inspection, the ProxyHandler doesn't allow the target requestURI to be completely overridden or to contain exchange attributes. But in this case we want the target requestURI to be rewritten using a value from the predicate context.
My questions are:
- Is this possible and I'm just missing it?
- If it's not possible, should the ProxyHandler be enhanced to allow it?
- Or should another handler be created instead that allows for this?
For what it's worth, this specific use case I'm looking at doesn't have a need for load balancing target hosts, but that's not to say it's not a valid use case. I'm also not sure how we'd add this functionality and still be backwards compat Currently if I have a proxy set up like so:
And I proxy a request with an original URI of /bar/ then the target URL ends up being
So the original requestURL just gets appended to any URI already present in the proxy host. To be able to provide the same sort of generic proxy available in other engines like Tuckey, we'd need the ability to
- Completely override the target requestURI
- Allow resolution of exchange attributes in the URL such as ${1}
Thoughts?
Thanks!
~Brad
Developer Advocate
Ortus Solutions, Corp