By default, Alibaba Cloud and DCDN support request headers that carry information, such as the client IP address. You can also configure custom headers. To customize origin requests, use the Modify Outgoing Request Header feature to add, delete, change, or replace HTTP request headers.
Prerequisites
This feature is not enabled by default. To use this feature for a domain, you must first submit a ticket to enable it.
Background
An HTTP request header is part of an HTTP request message. It passes specific parameters to a server.
When a or DCDN point of presence (POP) requests resources from an origin server, the server can read the information in the origin request header. This feature lets you rewrite HTTP request headers in origin requests to send specific parameters to the origin server.
To learn how an origin server reads the client IP address from the X-Forwarded-For header, see Obtain the client IP address.
Usage notes
An outgoing request is an HTTP message that is sent back to the origin server through or DCDN. The configuration for modifying outgoing request headers affects only HTTP messages that are sent back to the origin server through or DCDN. This configuration does not modify HTTP messages that are served directly to users from or DCDN nodes.
You cannot modify outgoing request headers for a wildcard domain name.
Alibaba Cloud and DCDN include the following HTTP request headers in origin requests by default, requiring no additional configuration.
Origin HTTP header
Description
Example
Ali-Cdn-Real-Ip
The client's real IP address for the connection to a or DCDN POP.
Ali-Cdn-Real-Ip:192.168.0.1
X-Forwarded-For
The IP addresses of the client and any intermediate or DCDN POPs.
X-Forwarded-For:192.168.0.1, 172.16.0.1
X-Client-Scheme
The application-layer protocol used by the client to send a request to a or DCDN POP, such as HTTP or HTTPS.
X-Client-Scheme:http
Host
The domain name of the origin server accessed in the origin request.
Host:example.com
Via
The names of all or DCDN POPs through which the client request passes.
Via:cn2546-10.l1, cache1.cn2546-10, l2cn2547-7.l2, cache1.l2cn2547-7
If you set the value of an outgoing request header to a variable, the variable is resolved to its actual value at runtime. The following variables are available.
Parameter
Origin HTTP header
Description
Example
Ali-Cdn-Real-Port
$http_Ali_Cdn_Real_Port
Adds the client's real port to the origin request header.
Ali-Cdn-Real-Port:80
Ali-Cdn-Real-Ip
$http_Ali_Cdn_Real_Ip
Adds the client's real IP address to the origin request header.
Ali-Cdn-Real-Ip:192.168.0.1
X-Forwarded-For
$proxy_add_x_forwarded_for
Adds the X-Forwarded-For header to the origin request to pass the client IP address and the intermediate proxy IP address to the origin server.
X-Forwarded-For:192.168.0.1, 172.16.0.1
Procedure
-
Log on to the DCDN console.
-
In the left-side navigation pane, click Domain Names.
-
On the Domain Names page, find the domain name that you want to manage and click Configure in the Actions column.
-
In the domain's navigation pane, click Origin Fetch.
-
Click the Modify Outgoing Request Header tab.
-
On the Modify Outgoing Request Header tab, click Add.
-
Configure the parameters for the header modification.
ImportantIf multiple conflicting operations target the same origin request header, only the one with the highest priority is executed. The priority order from highest to lowest is: . For example, if you configure both an Add and a Delete operation for the same header, only the Add operation is executed.
-
Click OK.