Due to the website's server being located domestically, accessing it from abroad is very slow. Separating the parsing requests for domestic and foreign access, where domestic access uses domestic lines and foreign access uses Cloudflare, can effectively improve the speed of foreign access.
The following items need to be prepared#
A Cloudflare account, a PayPal account linked to a bank card (used to activate the free Cloudflare for SaaS, so the bank card can have no balance), and a little bit of time.
Register a domain name for relay#
First, go to EU.org to register a free second-level domain:
Once there, please ignore the website's minimalist design, click Sign-in or sign-up here! -> Register to create an account. The required fields are: Name, E-mail, Address (line 1), Address (line 2), Country, Password, Confirm Password. After filling these out, check the option that says you have read and accepted the domain policy to complete the account registration.
Important
It is important to note that the Name field seems to require a space and cannot contain numbers; for example, entering Vinking
will result in an Enter a valid value. error, while entering Vinking loma
will pass validation. Additionally, Address (line 1) and Address (line 2) can be filled in arbitrarily, but cannot be left blank.
Next, you will receive a verification email:
Click the link nic.eu.org/arf/XXX to verify your email. After completing this, copy the XXX-FREE
that follows nic-hdl in the email and paste it into the Handle text box on the login page, with the password being the one you just set.
After logging in, click New Domain to register a domain name, first filling in Complete domain name (the domain you want to register; you can click the list below to see available domain suffixes). Here, we will take the application for the free domain vinkingtest.eu.org
as an example for the following introduction.
Next, we need to go to Cloudflare to add a site (at this point, the domain name has not yet been fully registered, so please do not close the domain registration page).
Click add site -> fill in the domain name you just applied for (for example, here it is vinkingtest.eu.org
) -> select the free plan -> skip adding DNS records, and finally, you will get two Cloudflare name servers kenneth.ns.cloudflare.com
and malavika.ns.cloudflare.com
.
Return to the domain application page and fill them into the Name1 and Name2 fields at the bottom of the Name servers section. After clicking Submit, if you see No error, applying changes... Done, it means the domain registration has been completed. For Cloudflare, you need to click Finish, check name servers to complete the domain access.
Wait#
EU.org takes some time to complete the domain registration, ranging from a few minutes to a week. Personally, I waited about two to three hours before receiving the email confirming the successful registration of the domain, and Cloudflare will also send an email confirming the successful activation of the domain, at which point you can proceed to the next step.
Parse Subdomain#
First, enter the free domain you just applied for in Cloudflare, click DNS, and add a subdomain resolution. This subdomain will be used as a relay domain. You can refer to the settings below for specific entries; here we will use i
as the name:
SaaS Access#
Next, in the SSL/TLS section, enable Cloudflare for SaaS under Custom Hostnames. You will need to link a PayPal bank card to subscribe. Cloudflare for SaaS offers one hundred custom hostnames for free, which is sufficient for individual users, and for any additional ones, the price is $0.1 each per month.
Note
If you need to cancel your subscription, click the profile icon in the upper right corner -> Billing -> Subscriptions -> Cancel.
After enabling SaaS, add a Fallback Origin. The fallback origin is the subdomain you just resolved, so here my fallback origin is i.vinkingtest.eu.org
. After adding it, if there are no issues, the fallback origin status will show as valid.
Next, click Add Custom Hostname, and for the custom hostname, fill in your website name; here we will use vinking.top
as an example. Additionally, if your website does not need to support outdated browsers like IE6, it is recommended to set the minimum TLS version to TLS 1.1 or higher to improve security. You can refer to the following settings for filling:
After completing the settings for adding a custom hostname, you will receive two records: Certificate Validation and Hostname Pre-validation. Next, you need to add two corresponding resolutions at your domain service provider (such as Tencent Cloud, Alibaba Cloud, etc.).
Domain Service Provider Access#
Once the Certificate Validation and Hostname Pre-validation records are validated in Cloudflare (with both certificate status and hostname status showing as valid), we also need to add a resolution request at the domain service provider with the source being overseas, and the record value being the Fallback Origin (here it is i.vinkingtest.eu.org
) as a CNAME record. At this point, our domain DNS resolution will have two CNAME records to handle different request sources.
If we access the website using a foreign IP and see the page below, it indicates that the resolution was successful.
This article is synchronized and updated by Mix Space to xLog. The original link is https://www.vinking.top/posts/codes/improve-website-speed-with-cloudflare-dns