Use header modification to change headers in a request before it is routed to a backend service, or in a response before it is returned to a client. This topic explains how to configure header modification rules for a cloud-native gateway.
Procedure
-
Log on to the MSE console. In the top navigation bar, select a region.
-
In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the ID of the gateway.
-
In the left-side navigation pane, click Routes. Then, click the Routes tab.
-
For the routing rule that you want to modify, click Policies in the Actions column.
-
In the Policies section, click Header Modification, then click the
icon or Add Rule on the right. -
Configure the rule parameters and then click Save in the upper-right corner.
Parameter
Description
Header Type
Select the header type. Valid values: Request and Response.
-
Request: Modifies the headers of the incoming request.
-
Response: Modifies the headers of the outgoing response.
Action Type
Select the action type. Valid values: Add, Modify, and Delete.
-
Add: Adds a header to the request or response.
NoteIf a header with the same name already exists, the new header value is appended to the existing value and separated by a comma (,).
-
Modify: Modifies a specified header in the request or response.
Note-
If the specified header does not exist, the system adds a new header with the specified header key and header value.
-
If the specified header exists, the system overwrites its value.
-
-
Delete: Deletes a specified header from the request or response.
Header Key
Enter the name of the header.
Header Value
Enter the value of the header.
-
-
After you configure the header modification rule, turn on the Enable switch.
-
If enabled, the gateway modifies request and response headers according to the configured rules.
-
If disabled, the gateway does not modify request or response headers.
-
Result verification
As an example, assume you have configured a rule to add a test header to a response.
-
Run the following command to send a test request:
curl -I http://121.196.XX.XX/demo/item/list // The ingress IP address of the gateway -
The response includes the
test:demoheader:HTTP/1.1 200 OK x-content-type-options: nosniff x-xss-protection: 1; mode=block cache-control: no-cache, no-store, max-age=0, must-revalidate pragma: no-cache expires: 0 x-frame-options: DENY content-type: application/json content-length: 86 date: Tue, 30 Nov 2021 03:03:04 GMT x-envoy-upstream-service-time: 4 test: demo server: istio-envoy