proxy-request Action
The proxy-request
action forwards the incoming request almost unmodified to an upstream system.
The HTTP method and the request body are taken as-is from the client request. Cookie
, Authorization
and any hop-by-hop header fields like Connection
will be dropped automatically, the remaining header fields will be sent upstream.
The response body is written into fit://request/content/main
where it can be directly accessed with the body
or the content
function. Additional information about the response, such as headers and status code can be found in the $upstream
variable.
Usage
Just like an ordinary request
the proxy-request
can be configured using a JSON template with the following properties:
origin
origin
Sets the origin of the upstream system. Either origin
or url
is required. Type: string
.
stripEndpoint
stripEndpoint
To be used in connection with origin
. If true
, strips the endpoint path from the client request URL path before it is added to the upstream origin. Type: boolean
, default: false
E.g.
For the client request URL https://client.example.com/api/foo/bar
, the path is stripped to /
.
For the client request URL https://client.example.com/api/wildcard/path/to
, the path is stripped to /path/to
.
addPrefix
addPrefix
Inserts a path prefix before the given (client request URL) path, after possible endpoint stripping (see stripEndpoint
). Type: string
.
url
url
Sets the URL to the upstream system. Either url
or origin
is required.
query
query
Overrides the query part of the URL. See the request
action for the query
syntax.
headers
headers
Sets or removes request header fields. The syntax is the same as in the request
action. To remove a header, set its value to ""
.
options
options
Sets request options. See the request
action options for valid options.
Note: that, with proxy-request
, in contrast to request
, the defaults for exit-on-error
, validate-request
and validate-response
are true
, if a definition
is configured.
Examples
Using origin
:
With the client request URL http://client.example.com/my/api/foo/bar
matching the swagger definition path
the upstream request URL will be https://example.com/path/to/api/bar
.
Using url
:
See also
request
action (reference)
Last updated