当前位置:网站首页>The results of CDN node and source station are inconsistent

The results of CDN node and source station are inconsistent

2022-06-23 08:44:00 Ice cream pieces

Knowledge point

CDN As a distributed acceleration system , No matter how , Just as an acceleration , No changes will be made to the resource , The content returned to the customer should be consistent with the source site

Problem description

Client requests go through CDN The result of a node is different from that of a direct access to the origin

Problem analysis

When a client request arrives CDN After node , Will make the following judgments

Hit the cache and the cache data is not expired

CDN The node directly returns the result to the client

Miss cache

CDN Nodes forward client requests , At the same time HTTP Request Header Append some specific parameters to the request header , Final request origin

Schematic diagram

In some cases , Source station for HTTP Request Header The specific parameters appended to the request header will be handled differently , As a result, the result after the client request is processed is inconsistent with the direct access source station

for example : The origin will determine whether the request header contains Via Parameters , This confirms whether the request is from the proxy server , And then respond differently .

Solution

Proceed through the following two steps

  1. Locate the request parameter that caused this problem
  2. Modify the origin configuration or delete the problem parameters

Step one : Locate the request header parameter that caused this problem

Because the source station only returns different results for specific request header parameters , So you need to locate the specific parameter first . The positioning steps are as follows

Locally through the following curl The command directly accesses the origin , And record the returned results

curl -voa 'http://www.[$Your_Wesbite].com' -x [$Source_Server_IP]:[$Source_Server_Port]
  • [$Your_Wesbite]: Refers to your website domain name .
  • [$Source_Server_IP]: Refers to the public network of the origin server IP Address .
  • [$Source_Server_Port]: Refers to the website port of the origin server , Usually this port is 80 or 443.

Locally through the following curl command , Attach Alibaba cloud CDN Node specific request header parameters , Then request the origin , And record the returned results

curl -voa 'http://www.[$Your_Wesbite].com' -x [$Source_Server_IP]:[$Source_Server_Port] -H 'header'

Contrast steps 1 And steps 2 Result , Check for inconsistencies

Consistent result . Please cycle through the steps 1 And steps 2, Also replace step 2 Request header parameter in , Until the results are inconsistent .

The results are different . Record the request header parameters with different results , Then proceed to the next step .

Step two : Modify the origin configuration or delete the problem parameters

When locating the specific request header parameter , Refer to the following two methods for processing :

Modify origin configuration

Please check the source station Web Server configuration , Whether there is a configuration with different responses according to different request headers . If there is , Please adjust according to the actual needs

stay CDN The console deletes the appended request header parameter

If the located request header parameter has no practical effect on your business , You can go to CDN The console configuration deletes the request header parameter . About how to delete a request header parameter reference

https://help.aliyun.com/document_detail/155768.htm?spm=a2c4g.11186623.0.0.611123896ux0Lc

CDN Specific parameters appended to the node
Via: cn2**6.l1, vcache10.cn**36, l2cn**5.l2, cache28.l**35
Eagleeye-Traceid: 24689aa4*******58162753e
Ali-Swift-Log-Host: test.***.cn
Ali-Swift-Stat-Host: level2.test.***.cn
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

Important parameter description

  • Via: The request went through CDN Node information .
  • Ali-Cdn-Real-Ip: The client is real IP Address .
  • Ali-Swift-Range-Cache: If you enable Range Back to the source ,CDN The node will append this parameter , See configuration for details range Back to the source .

https://help.aliyun.com/document_detail/27129.htm?spm=a2c4g.11186623.0.0.61112389BDrxq1

  • X-Forwarded-For: The standard HTTP XFF Field .

Summary

User pass URL When accessing resources , When a real customer accesses resources, he does not care whether the resources of the node and the source site are consistent , It's usually cdn According to the manufacturer's customer feedback, the result of accessing the node is inconsistent with that of directly accessing the source station, or the node pulls resources back to the source and is inconsistent with that of the source station , When the user passes URL When accessing resources , If the node resource expires, the node forwards the client request , At the same time HTTP Request Header Append some specific parameters to the request header , Request origin , Source station for HTTP Request Header The specific parameters appended to the request header will be handled differently , As a result, the result after the client request is processed is inconsistent with the direct access source station . If the request header parameter is not required , It can be adjusted according to the situation , At the same time, pay attention to whether the domain name is configured gzip Compress 、 Picture conversion 、 Back to the source url rewrite , Generally, you can consider refreshing the nodes and source stations .

doubt

Under certain circumstances , Source station for HTTP Request Header The specific parameters appended to the request header will be handled differently

When a client request arrives CDN After node , Who will judge whether it hits or not cdn Node and whether the cache is expired

原网站

版权声明
本文为[Ice cream pieces]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201101847379344.html