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 add, delete, change, or replace HTTP headers in outgoing requests to the origins.
Background information
HTTP request headers are a component of the header section in requests that are transmitted over HTTP. Outgoing 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. 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 outgoing request headers for wildcard domain names.
By default, ApsaraVideo VOD supports the following HTTP request headers for origin requests. You do not need to configure them.
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
Procedure
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > CDN Configuration > Domain Names.
Find the domain name that you want to manage and click Configure in the Actions column.
In the navigation pane on the left of the specified domain name, click Back-to-Origin.
Click the Origin HTTP Request Headers tab.
Click Add and configure the origin HTTP request header.
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 to complete the configuration.
Configuration examples
Example 1
Scenario: Add X-Forwarded-For information to origin request headers to send the client IP address and proxy server IP addresses to the origin server.
By default, the X-Forwarded-For header is included in back-to-origin requests. If you do not need to modify the name of the X-Forwarded-For header, no additional configuration is required.
Configuration method:
Custom request header name: X-Forwarded-For.
Header value: $proxy_add_x_forwarded_for.

Custom request header name: X-Forwarded-For.
Header value: $proxy_add_x_forwarded_for.
Example 2
Scenario: Add the client's originating IP address to origin request headers to send the IP address to the origin server.
By default, the Ali_Cdn_Real_Ip header is included in back-to-origin requests, and its value is the client's originating IP address. If you do not need to modify the name of the Ali_Cdn_Real_Ip header, no additional configuration is required.
Configuration method:
Custom request header name: X-Real-IP.
Header parameter: $http_Ali_Cdn_Real_Ip.

Example 3
Scenario: Add the client's originating port to origin request headers to send the port number to the origin server.
By default, the Ali_Cdn_Real_Port header is included in back-to-origin requests, and its value is the client's originating port. If you do not need to modify the name of the Ali_Cdn_Real_Port header, no additional configuration is required.
Configuration method:
Custom request header name: X-Real-Port.
Header parameter: $http_Ali_Cdn_Real_Port.




