All Products
Search
Document Center

:The results obtained by accessing Alibaba Cloud CDN series products are different from those obtained by directly accessing the origin server

Last Updated:May 10, 2022

Description

After enabling acceleration for Alibaba Cloud Content Delivery Network series products (Alibaba Cloud Content Delivery Network, D Alibaba Cloud Content Delivery Network, S Alibaba Cloud Content Delivery Network), the result of client requests passing through Alibaba Cloud Content Delivery Network nodes is different from that of directly accessing the origin server.

Cause

When the client request reaches the Alibaba Cloud Content Delivery Network node, the following decisions are made:

  • The node Alibaba Cloud Content Delivery Network the hit cache
    directly returns the result to the client.
  • The node Alibaba Cloud Content Delivery Network the miss cache
    forwards the client request and appends some specific parameters to the HTTP Request Header request header to finally request the origin, which is commonly known as "back-to-origin". The schematic diagram is as follows.

In some cases, the origin server has different processing methods for specific parameters appended to the HTTP Request Header request header. As a result, the result of client request processing is inconsistent with that of direct access to the origin server. For example, the origin server determines whether the request header contains the Via parameter to confirm whether the request is from the proxy server, and then responds differently.

Solution

Process through the following two steps:

  1. Locate the request header parameters that cause this problem
  2. Modify origin configurations or delete problem parameters

Step 1: Locate the request header parameters that cause this problem

The origin server returns different results only for a specific request header parameter, so you need to locate the specific parameter first. The positioning steps are as follows:

  1. Run the following curl command to access the origin server and record the returned results.
    curl -voa 'http://[$Your_Wesbite]' -x [$Source_Server_IP]:[$Source_Server_Port]
    Note:
    • [$Your_Wesbite]: refers to the domain name of your website.
    • [$Source_Server_IP]: indicates the public IP address of the origin server.
    • [$Source_Server_Port]: refers to the website port of the origin server. Generally, the port is 80 or 443.
  2. Run the following curl command locally to attach the specific request header parameters of the Alibaba Cloud CDN node. Then, request the origin server and record the returned result.
    curl -voa 'http://www.[$Your_Wesbite].com' -x [$Source_Server_IP]:[$Source_Server_Port] -H 'Via:example.aliyundoc.com'
    Note: This example uses "Vi a:example.aliyundoc.com". You can customize request header parameters and values on site. For more information about Alibaba Cloud CDN additional request header parameters, see more information.
  3. Compare the results of Step 1 and Step 2 to check for inconsistencies.
    • The results are consistent.
      Cycle through Step 1 and Step 2 and replace the request header parameters in Step 2 until the results are inconsistent.
    • The results are different.
      Record the request header parameters when the results are different, and then proceed to the next step.

Step 2: Modify origin configurations or delete problem parameters

When locating specific request header parameters, refer to the following two methods:

  • To modify the origin configurations
    , check the Web server configurations of the origin to see if there are configurations that have different responses based on different request headers. If it exists, please adjust it according to actual needs.
  • Delete the appended request header parameter
    in the Alibaba Cloud Content Delivery Network console. If the detected request header parameter has no actual effect on your business, you can configure and delete the request header parameter in the Alibaba Cloud Content Delivery Network console. For more information about how to delete request headers, see Configure back-to-origin HTTP request headers.
    Note: Currently, only Alibaba Cloud CDN products support deleting HTTP request headers. SCDN and DCDN are not supported. If your business needs, submit a ticket to contact Alibaba Cloud technical support.

References

The following example describes the specific parameters that are appended to a Alibaba Cloud Content Delivery Network node.

Via: cn2**6.l1, vcache10.cn**36, l2cn**5.l2, cache28.l**35
Eagleeye-Traceid: 24689aa4*******58162753e
Ali-Swift-Log-Host: example.aliyundoc.com
Ali-Swift-Stat-Host: demo.example.aliyundoc.com
X-Forwarded-For: 58.***.***.41
X-Client-Scheme: http
Ali-Cdn-Real-Ip: 58.***.***.41
Ali-Swift-5Xx-No-Retry: on
Cdn-Src-Ip: 127.0.0.1
Ali-Swift-Range-Cache: on

Description: The following table lists important parameters.

  • Via: the information about the Alibaba Cloud Content Delivery Network node that is validated by the request.
  • Ali-Cdn-Real-Ip: the real IP address of the client.
  • Ali-Swift-Range-Cache: If you enable Range back-to-origin, this parameter is appended to the Alibaba Cloud Content Delivery Network node. For more information, see Configure Range back-to-origin.
  • X-Forwarded-For: standard HTTP XFF fields.

Application scope

  • CDN
  • DCDN
  • SCDN