By default, Alibaba Cloud CDN supports request headers such as client IP addresses. You can also configure custom request headers. Alibaba Cloud CDN allows you to rewrite HTTP headers in origin requests. You can add, delete, change, or replace HTTP headers in origin requests based on your business requirements.
Background information
HTTP request headers are a component of the header section in requests that are transmitted over HTTP. HTTP request headers include specific parameters that are sent to servers.
When points of presence (POPs) retrieve the requested resources from an origin server, the origin server can obtain information that is included in request headers. Alibaba Cloud CDN allows you to rewrite HTTP headers in origin requests. The information that is included in request headers is passed to the origin server to meet specific business requirements. For example, you can configure the X-Forwarded-For (XFF) header to pass client IP addresses to your origin server.
For information about how the origin server obtains the IP address of a client from the XFF header in the origin request, see Retrieve the originating IP addresses of clients.
Usage notes
An origin request is an HTTP message that is transmitted by Alibaba Cloud CDN to the origin server of a specific accelerated domain name. A rewrite rule rewrites only the HTTP headers in requests that are transmitted between an origin server and POPs. A rewrite rule does not rewrite the HTTP headers in requests that are transmitted between POPs and clients.
You cannot specify custom HTTP request headers for wildcard domain names.
By default, Alibaba Cloud CDN supports the following HTTP request headers, which do not need to be configured.
Origin HTTP header
Description
Example
Ali-Cdn-Real-Ip
The IP address that is used by the client to connect to a POP.
Ali-Cdn-Real-Ip:192.168.0.1
X-Forwarded-For
The IP address of the client and IP address of a POP that is used to connect to the origin server.
X-Forwarded-For:192.168.0.1, 172.16.0.1
X-Client-Scheme
The protocol that is used by the client to send the request to a POP, such as HTTP or HTTPS.
X-Client-Scheme:http
Host
The domain name of the origin server to which the request is redirected.
Host:example.com
Via
The names of all POPs that the request passes through.
Via:cn2546-10.l1, cache1.cn2546-10, l2cn2547-7.l2, cache1.l2cn2547-7
If the value of the HTTP request header is a variable, a specific value is assigned to the variable when the variable is used. The following table describes available variables.
Parameter
Origin HTTP header
Description
Example
Ali-Cdn-Real-Port
$http_Ali_Cdn_Real_Port
Adds a header that passes the client port to the origin server.
Ali-Cdn-Real-Port:80
Ali_Cdn_Real_Ip
$http_Ali_Cdn_Real_Ip
Adds a header that passes the client IP address to the origin server.
Ali-Cdn-Real-Ip:192.168.0.1
x_forwarded_for
$proxy_add_x_forwarded_for
Adds the XFF header to origin requests. The XFF header passes the client IP address and proxy IP address to the origin server.
X-Forwarded-For:192.168.0.1, 172.16.0.1
Procedure
Log on to the Alibaba Cloud CDN 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 Manage in the Actions column.
In the left-side navigation tree of the domain name, click Origin Fetch.
Click the Custom Request Header tab.
Click Customize.
Configure the parameters in the dialog box that appears.
ImportantWhen different operations are performed on the same request header at the same time, the operations have different priorities. The operations are prioritized in the following descending order: Replace > Add > Change or Delete. For example, if you perform the Add and Delete operations on the same request header at the same time, the request header is added and then deleted.
Parameters of the Add operation
Parameters of the Delete operation
Parameters of the Change operation
Parameters of the Replace operation
Click OK.