Configuration Reference
The Traffic Policy configuration reference for this action.Supported Phases
on_http_request
, on_http_response
Type
add-headers
Configuration Fields
Map of header key to header value to be added.Minimum
1
, Maximum 10
.Behavior
When configured in theon_http_request
phase, this action will add the specified headers to incoming http requests before reaching the upstream server. When
configured in the on_http_response
phase, the specified headers are added to the http response from the upstream server.
Addition Only
This action will only add headers to the request or response. If the header already exists it will append another header with the same key unless it is thehost
header,
see Special Cases.
To replace or remove headers use the remove-headers
action then
add the header with the desired value.
Case Sensitivity
Header keys added through this action are normalized to lowercase per the HTTP/2 specification.Ordering
Since actions are run in the order they are specified, to modify headers that have been added by other actions you must place this action after them in your traffic policy document.Special Cases
- Adding the
host
header override the existing value instead of appending another header. - You may not add or remove the
user-agent
header. - You may not use this action to add the
ngrok-skip-browser-warning
header to skip the ngrok browser warning on free accounts. For more information, check out the free plan limits guide.
Examples
Adding Client IP Headers to all HTTP requests
The following Traffic Policy configuration will add the client IP address to all HTTP requests.Example Traffic Policy Document
x-client-ip
with the value${conn.client_ip}
to demonstrate the use of CEL interpolation to include the client IP address.
Example Request
Adding headers to an HTTP response
The following Traffic Policy configuration will add headers to the response from the upstream service when the method isGET
and the URL starts with /status/200
.
Example Traffic Policy Document
x-custom-header
with the valuemy-custom-value
x-string-interpolation-example
with the valuestarted at ${conn.ts.start}
to demonstrate the use of CEL interpolation to include the request connection start time.
Example Request
Action Result Variables
The following variables are made available for use in subsequent expressions and CEL interpolations after the action has run. Variable values will only apply to the last action execution, results are not concatenated.Map of headers that were added by the action.