Symptoms

After you use Alibaba Cloud CDN to accelerate your domain name, the browser displays the following message after users access the domain name: This page isn't working. xxx redirected you too many times. Error message: ERR_TOO_MANY_REDIRECTS.

Causes

The browser limits the maximum number of redirects for a single request. For example, Chrome terminates a request after it is redirected more than 20 times and prompts the too many directs error.

If this error never occurred before Alibaba Cloud CDN is used, and occasionally occurs after Alibaba Cloud CDN is used, the origin server may be improperly configured, resulting in an infinite redirection loop during back-to-origin routing.

Common cause: When forced redirection over HTTPS is enabled for the origin server, back-to-origin requests over HTTP are redirected to HTTPS. In this case, if origin port 80 or the static origin protocol policy is configured for the domain name, back-to-origin requests over HTTP may cause an infinite loop.

For example, if origin port 80 is configured, the logic of the redirection loop is:
  1. The client accesses the accelerated domain name http://example.aliyun.com/.
  2. Alibaba Cloud CDN specifies port 80 for back-to-origin routing. When back-to-origin requests are sent to the origin server over HTTP, the origin server redirects the requests to https://example.aliyun.com/.
  3. The client accesses the redirected URL https://example.aliyun.com/.
  4. Because Alibaba Cloud CDN specifies port 80 for back-to-origin routing, the back-to-origin requests are still sent over HTTP, and the origin server redirects the requests to https://example.aliyun.com/ again.
  5. The client accesses the redirected URL https://example.aliyun.com/ again, after which Steps 3 and 4 are infinitely repeated.
As shown in the preceding logic, when Alibaba Cloud CDN specifies port 80 for back-to-origin routing, back-to-origin requests are sent over HTTP, regardless of whether the client accesses the domain name over HTTP or HTTPS. When forced redirection over HTTPS is enabled for the origin server, an infinite redirection loop occurs.

Solutions

If the issue that you encounter meets the preceding logic, you can modify the back-to-origin configuration by performing the following steps.

  1. Set the origin port to 443. For more information, see Configure an origin server.
    Configure the port
  2. Disable the static origin protocol policy, or specify HTTPS as the protocol for back-to-origin routing. For more information, see Configure the origin protocol policy.
    Configure the static origin protocol policy
  3. Submit a directory refresh task to refresh the root directory. For more information, see Refresh and prefetch resources.
    Refresh directories
  4. After the refresh task is complete, clear the local browser cache, and try again.