Due to slow access to GitHub Pages from within the country, the author applied for a personal domain and purchased CDN acceleration services from a domestic cloud host provider. During the configuration process, the author encountered an issue where the www subdomain could not be accessed, which was ultimately resolved by deleting the generic domain DNS record and setting up a second-level domain separately. The author also shared the principles and configuration experience of CDN acceleration, as well as their attempts and lessons learned using reverse proxy with Nginx.
Background
The website is hosted on GitHub Pages, and due to some well-known reasons, accessing GitHub Pages internally can be slow. Therefore, I applied for a personal domain name and purchased CDN acceleration services from a domestic cloud host provider. When configuring the acceleration service, I thought about my development machine, which has Docker, frp, k8s, and other services deployed on it – all with their respective dashboards. Following the principle of not wasting anything, I configured several reverse proxies, all using subdomains.
When I was happily using these subdomains, I discovered that the www subdomain could no longer be accessed. In the Alibaba Cloud console, I had configured DNS to resolve both www.xiangtianlong.com and xiangtianlong.com, and hadn’t yet enabled CDN acceleration; at that time, both domains were working normally.
When configuring CDN acceleration, due to a large number of subdomains, I enabled generic domain rules, which unified routed all traffic to the development machine. As a result, the www subdomain also went down – yes, you read that right, the “www” prefix was a subdomain. In reality, the website is deployed on GitHub Pages, and the development machine has no caching information for the site.
As for why the website wasn’t deployed on the development machine, it’s because it’s a static blog, paired with GitHub’s action to automatically integrate publishing – truly delicious!
Domain
Non-professional web development, the understanding of domains does not involve SEO or cross-origin issues. As a blog site, a bare domain easily highlights the blogger’s site, such as myself who uses Chinese pinyin as my domain name, and given that mobile access is now more prevalent, it’s preferable to input fewer characters.
Keyboard shortcuts can be used on desktop to avoid entering “www” and “com”.
CDN
I’ve used both Alibaba Cloud and Tencent Cloud, and it’s easy for newcomers to get started. Tencent Cloud also has dedicated video explanations of the related concepts. The principle of CDN acceleration is similar to that of a JD.com warehouse: new products are pre-distributed to warehouses across China, and when delivery requests are triggered, they’re distributed locally.
Origin Address: The address where the original website resources are stored.
Cache file settings: Using F12 in your browser’s developer console to analyze static and dynamic resources.
- All 0 days validity
.php;.jsp;.asp;.aspx
0 days validity.jpg;.png;.js;.css;.woff2
1 day validity
Tencent Cloud configuration rules:
- You can configure up to 10 cache expiration rules.
- The priority of multiple cache expiration rules is bottom-first.
- Cache expiration time can be set up to a maximum of 365 days.
Miserable Confession
I had never used Nginx before, assuming that just searching for a website would reveal the configuration for reverse proxy. The result was quite confusing, and I spent half a day without even getting a 302 redirect to work. So, I decided to take a brute-force approach – deleting wildcard domain resolution patterns in DNS parsing and setting up individual second-level domains. Suddenly, I noticed that Alibaba Cloud DNS had a feature called “Display URL Redirect,” which worked perfectly as a 302 redirect.
I set up the first second-level domain normally, and then when I tried to set up the second one, it didn’t work. I was starting to doubt my sanity. After waiting for a while, it suddenly started working – apparently, Alibaba Cloud DNS sometimes has hiccups with its DNS propagation.