[CDN FAQ] Test Method for binding CDN domain names to origin sites-Alibaba Cloud Developer Community

an access exception occurs after you use CDN. When you troubleshoot the problem, you must bypass CDN to check whether the problem is related to the origin, directly access the origin site to compare the CDN acceleration and unaccelerated access effects. One method is to change the domain name resolution record, and the other is to directly bind the local Host to the source site for access. This topic describes how to point a domain name to the origin site without modifying the domain name resolution.

you can modify the hosts file to point the domain name to the origin site without modifying the domain name resolution. The specific method is as follows.

1. Edit the hosts file

note: when accessing a domain name in a browser, the IP address of the domain name is obtained from the hosts file first. If no corresponding entry exists in the hosts file, the local DNS server is used to obtain the IP address to which the domain name resolution points.

  • In the Windows system, the file is stored in the following path: C:WindowsSystem32driversetchosts
  • in Linux, the file is stored in the following path:/etc/hosts

2. Add an entry at the end of the hosts file. In this example, 1.1.1.1 is the IP address of the origin site and www.test.com is the domain name to be checked.

3. Run the following command to test the domain name and confirm that the returned IP address is 1.1.1.1.

ping www.test.com

4. Clear the cache of the browser and restart the browser to access the website. Data is obtained from the IP address 1.1.1.1 instead of CDN acceleration. Open the browser developer mode and switch to the Network tab. Under the General, you can see that the actual accessed Remote Address is 1.1.1.1.

Note: If the browser prompts an error, the origin site has a problem.

use the curl tool to initiate HTTP/HTTPS requests and bind them to the origin site for testing by specifying parameters. Assume that 1.1.1.1 is the origin IP address and www.test.com is the domain name to be checked.

1. If the curl tool is not available, install curl tool 2 first. Windows, open the command line window in cmd in the run bar and run the curl Command. Run Mac/Linux directly under the command line tool.

1. The origin site is port 80.

curl -voa "http://www.test.com/" -x 1.1.1.1:80

2. The origin site is port 443.

curl -voa "http://www.test.com/" --resolve www.test.com:443:1.1.1.1

3. The origin site is a custom port.

curl -voa "http://www.test.com/" -x 1.1.1.1:自定义端口号

Note: If you are testing a custom port (not port 80/443), you must use the HTTP protocol.

Selected, One-Stop Store for Enterprise Applications
Support various scenarios to meet companies' needs at different stages of development

Start Building Today with a Free Trial to 50+ Products

Learn and experience the power of Alibaba Cloud.

Sign Up Now