I am trying out the rewrite feature.
The goal here is to cature everything begin with /sdf/(.*)
and request to another upstream provider.
And in the gateway logs, I am seeing:
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Rewriter active"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="/sdf/2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Inbound path: /sdf/2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Rewriter checking matches, len is: 1"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="[[/sdf/2/ 2/]]"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="[[$1]]"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Replacing: $1"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="URL Re-written from: /sdf/2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="URL Re-written to: http://httpbin.org/get?q=2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Detected a host rewrite in pattern!"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Started proxy"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Stripping: /"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Upstream Path is: get"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Serving Multi-target..."
gateway_1 | time="Mar 1 06:59:18" level=debug msg="UPSTREAM REQUEST URL: http://httpbin.org/get?q=2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Detected host rewrite, notifying director"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Detected host rewrite, overriding target"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Outbound Request: http://httpbin.org/get?q=2/"
gateway_1 | time="Mar 1 06:59:18" level=debug msg="Upstream request took (ms): 321.94604699999996"
However, the response I am getting back from the gateway is:
curl -v http://tyk.api.com:8080/sdf/2/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to tyk.api.com (127.0.0.1) port 8080 (#0)
> GET /sdf/2/ HTTP/1.1
> Host: tyk.api.com:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Connection: close
< Content-Type: text/html
< Date: Thu, 01 Mar 2018 07:04:09 GMT
< Server: meinheld/0.6.1
< Via: 1.1 vegur
< X-Ratelimit-Limit: 0
< X-Ratelimit-Remaining: 0
< X-Ratelimit-Reset: 1519887859
< Content-Length: 84
<
* Closing connection 0
<html><head><title>Bad Request</title></head><body><p>Bad Request.</p></body></html>
I even tried to rewrite the header value with the proper Host
value, but that is not working as well.