Skip to content
thiagobustamante edited this page May 27, 2017 · 30 revisions

Configure how requests must be proxied to the target API.

The Proxy configuration object must be included in the API config and supports the following properties:

Property Type Description Required
target Target The target of the proxied API. true
supressViaHeader boolean Tree Gateway adds a Via header on response by default. Yhis option can be used to disable it. false
filter Filter[] A List of request filters to be added, in order, to the request pipeline. false
interceptor Interceptors Configure request and response interceptors to be added to the request pipeline. false
preserveHostHdr boolean If true, the gateway will copy the host HTTP header to the proxied express server. false
timeout string or number Configure a specific timeout for requests. Timed-out requests will respond with 504 status code and a X-Timeout-Reason header. You can inform the amount of milisencods, or use a human-interval string false
disableStats boolean If true, disable the statistical data recording for request accesses. false
statsConfig StatsConfig Configurations for this API stats. false
limit string This sets the body size limit (default: 1mb). If the body size is larger than the specified (or default) limit, a 413 Request Entity Too Large error will be returned. See bytes.js for a list of supported formats. This option is ignored if parseReqBody is false. false
parseReqBody boolean Allows you to control when to parse the request body. Just enable it if you need to access the request.body inside a proxy middleware, like a filter or interceptor. If disabled, the request is streamed to the target API, increasing performance. Defaults to false. false
parseResBody boolean Allows you to control when to parse the response data. Just enable it if you need to access the response body inside a proxy response interceptor middleware. If disabled, the response is streamed from the target API, increasing performance. Defaults to false. false

Target

Configure the target of the proxied API.

It supports the following properties:

Property Type Description Required
host string The proxy target host. true
allow string[] A list of group names that is allowed to access the target API. false
deny string[] A list of group names that is not allowed to access the target API. false

Example:

{
    "proxy": {
        "target": {
            "host": "httpbin.org",
            "allow": ["Group1"],
            "deny": ["Group2"]
        },
        "timeout": "five seconds"
    }    
}

Filter

Configure request filters to the request pipeline. If you configure more than one filter, they are all applied following the same order as defined here into this list.

Each Filter Configuration has the following properties:

Property Type Description Required
name string The Filter name. true
group string[] A list of group names that should be filtered by this filter. If not provided, everything will be filtered. false

Example:

{
    "proxy": {
        "target": {
            "host": "http://httpbin.org"
        },
        "filter": [
            {
                "name": "myCustomFilter",
                "group": ["Group1"]
            },
            {
                "name": "mySecondFilter", 
                "group": ["Group2"]
            }
        ],
        "timeout": 5000
    }
}

Interceptors

Configure request and response to the request pipeline.

It supports the following properties:

Property Type Description Required
request Interceptor[] A list of request interceptor names true
response Interceptor[] A list of response interceptor names true

Interceptor

Configure a request or response interceptor.

It supports the following properties:

Property Type Description Required
name string The Interceptor name. true
group string[] A list of group names that should be intercepted by this interceptor. If not provided, everything will be intercepted. false

Example:

{
    "proxy": {
        "target": {
            "host": "http://httpbin.org"
        },
        "interceptor": {
            "request": [
                {"name":"myRequestInterceptor", "group": ["Group1"]},
                {"name":"mySecondRequestInterceptor"}
            ], 
            "response": [
                {"name":"myResponseInterceptor"}, 
                {"name":"SecondInterceptor", "group": ["Group1"]}
            ] 
        },
        "timeout": 5000
    }
}
Clone this wiki locally