You are browsing documentation for an outdated plugin version.
Kubernetes users: Version v1beta1
of the Ingress
specification does not allow the use of named regex capture groups in paths.
If you use the ingress controller, you should use unnamed groups, e.g.
(\w+)/
instead of (?<user_id>\w+)
. You can access
these based on their order in the URL path. For example $(uri_captures[1])
obtains the value of the first capture group.
In the following examples, the plugin is enabled on a service. This would work
similarly for routes.
Add multiple headers by passing each header:value
pair separately:
With a database
Without a database
curl -X POST http://localhost:8001/services/example-service/plugins \
--data "name=request-transformer" \
--data "config.add.headers[1]=h1:v1" \
--data "config.add.headers[2]=h2:v1"
plugins:
- name: request-transformer
config:
add:
headers: ["h1:v1", "h2:v1"]
incoming request headers |
upstream proxied headers: |
h1: v1 |
|
Add multiple headers by passing comma-separated header:value
pair (only possible with a database):
curl -X POST http://localhost:8001/services/example-service/plugins \
--data "name=request-transformer" \
--data "config.add.headers=h1:v1,h2:v1"
incoming request headers |
upstream proxied headers: |
h1: v1 |
|
Config as JSON body
Add multiple headers by passing config as a JSON body (only possible with a database):
curl -X POST http://localhost:8001/services/example-service/plugins \
--header 'content-type: application/json' \
--data '{"name": "request-transformer", "config": {"add": {"headers": ["h1:v1", "h2:v1"]}}}'
incoming request headers |
upstream proxied headers: |
h1: v1 |
|
Example: Adding a querystring and a header
With a database
Without a database
curl -X POST http://localhost:8001/services/example-service/plugins \
--data "name=request-transformer" \
--data "config.add.querystring=q1:v2,q2:v1" \
--data "config.add.headers=h1:v1"
plugins:
- name: request-transformer
config:
add:
headers: ["h1:v1"],
querystring: ["q1:v1", "q2:v2"]
incoming request headers |
upstream proxied headers: |
h1: v2 |
|
h3: v1 |
|
incoming request querystring |
upstream proxied querystring |
?q1=v1 |
?q1=v1&q2=v1 |
|
?q1=v2&q2=v1 |
Example: Appending and removing in one request
Append multiple headers and remove a body parameter:
With a database
Without a database
curl -X POST http://localhost:8001/services/example-service/plugins \
--header 'content-type: application/json' \
--data '{"name": "request-transformer", "config": {"append": {"headers": ["h1:v2", "h2:v1"]}, "remove": {"body": ["p1"]}}}'
plugins:
- name: request-transformer
config:
add:
headers: ["h1:v1", "h2:v1"]
remove:
body: [ "p1" ]
incoming request headers |
upstream proxied headers: |
h1: v1 |
|
incoming url encoded body |
upstream proxied url encoded body |
p1=v1&p2=v1 |
p2=v1 |
p2=v1 |
p2=v1 |