このページは、まだ日本語ではご利用いただけません。翻訳中です。
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.
Examples: Passing multiple headers in one request
Pass each header separately
Add multiple headers by passing each header:value
pair separately:
incoming request headers | upstream proxied headers: |
---|---|
h1: v1 |
|
Comma-separated header:value
pairs
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
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:
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 |