Solving the issue of unable to log in to the WordPress backend after configuring Baidu Cloud CDN

Publish: 2020-03-22 | Modify: 2020-03-22

Background

The blog originally used the Alibaba Cloud Singapore node, but it was often blocked by the ISP on port 443, resulting in the website being inaccessible. Fortunately, Baidu Cloud was running a promotion, and I purchased a 500GB traffic package for 55 yuan, so I applied Baidu Cloud CDN (not Baidu Cloud Acceleration) to solve this problem. At first, the cache rules were set incorrectly, causing the WordPress backend to be unable to log in. Here are some notes on configuring Baidu Cloud CDN for WordPress.

Image

Cache Expiration Time Configuration

The WordPress backend is a dynamic page, so /wp-admin/ does not need to be cached, and dynamic files like .php do not need to be cached either. Set the expiration time to 0 seconds, and set the expiration time for other caches according to your own situation.

Image

Disable Ignoring Parameters

Baidu Cloud CDN has ignoring parameters enabled by default, which ignores parameters like ?xxx=, but for dynamic programs like WordPress, this can cause many problems. Therefore, this feature is not needed.

Image

Disable 301/302 Redirect Following Origin

When the 301/302 follow-up of the source is enabled, if the node request returns a 301/302 status code, it will directly jump to get the resource without returning 301/302 to the user.

WordPress dynamically creates a 302 status code during login, so if the 301/302 redirect following origin is enabled, the redirection will not work properly. Therefore, this feature needs to be disabled.

Image

Pay Attention to the Protocol for Origin Retrieval

If your origin site is HTTP, you should choose HTTP origin retrieval. If the origin site can be accessed normally via HTTPS, you should choose HTTPS origin retrieval. Selecting the wrong protocol for origin retrieval may result in a loop redirection. My blog has SSL deployed, so I chose HTTPS origin retrieval.

Image

Pay Attention to the Forced HTTPS Redirection in HTTPS Configuration

If your site has deployed an SSL certificate and redirected port 80 to 443, i.e., the origin site has already set up HTTP redirection to HTTPS, then there is no need to set up forced HTTPS redirection on the CDN, otherwise it will cause a loop redirection.

Image

Finally

By making the above settings, the problem of the WordPress backend being unable to log in can be solved. This is for reference for those who need it. In addition, if the CDN is not properly configured, it will not only fail to accelerate the website, but may also cause exceptions. Therefore, it is necessary to configure it reasonably according to your own business scenario, otherwise it will backfire.


Comments