Use DNSPod and Squid to create their own CDN full sharing

  • 2020-05-07 20:44:50
  • OfStack

The object that this tutorial faces is individual stationmaster, so each respect can do one's best silly melon changes, let everybody can understand. Of course, the premise is that you need to have a studious heart, and perseverance.
On the other hand, Windows will not be covered in this article. The whole system will be built on CentOS Linux 5. Don't ask me why it's not Windows, because Windows can only be described in one word: bad. Friends who don't like Linux or think Linux is difficult to learn can stop here.
One might ask, why Linux, not FreeBSD? Because FreeBSD is not suitable for beginners, either from the optimal configuration of the system or the performance of the file system.
As mentioned earlier, this article is aimed at the individual webmaster who does not have much technical foundation, so the article will have the installation of Linux, the basic operation and so on 1 things to teach you, let you learn simple, time to spend valuable.
Again wordy 1, in the next time you will face a black, all English screen, please be prepared.


note: this tutorial will * not * cover the following:

1. Dynamic content (e.g. BBS)
2. Large files (such as software from the software download station)

Chapter 1 CDN and intelligent DNS
1. What is CDN
Simply put, CDN is something that makes your website faster to access. For example, if a netcom user accesses a file on the CDN server of netcom, the CDN system will determine whether the file has been requested or not. If the file has been requested, it will be read from the system cache and returned to the user without invalidating. If the file has not been requested, CDN will automatically fetch the file from your main server, cache it in the CDN system, and return it to the user.
Seeing this, the smart friends will ask: if the CDN server of netcom, access to my main server in telecom is slow, so is the first time the user requests this file will be slow? Hey, congratulations, that's true. In addition, when the file is not fully cached on CDN, all users accessing the file will make errors, such as incomplete page opening and half-downloaded file. But as long as your site gets enough traffic, the impact on users is negligible.
Then there are friends who ask, why doesn't CDN exist in business? Because the commercial CDN has its own leased line, it walks by itself. That's why commercial CDN is so expensive. Of course, how to take this route and build such a large CDN system is beyond the scope of this article.

2. What is smart DNS and what is DNSPod
The principle of intelligent DNS is very simple: when the user resolves a domain name, determine the IP of the user under 1, then match the IP table within the DNS server with 1, see if the user is a telecom or netcom user, and return the corresponding IP address to the user.
DNSPod is the web site of students with bra, which provides free intelligent DNS service. All you need to do is change the DNS of your domain name from your original registrar to DNSPod and you will be ready to use the service.
Note: DNSPod only provides intelligent domain name resolution service, does not provide a domain name and does not provide a server, do not think that your domain name to DNSPod can become a double line.
Chapter 2 preliminary preparation

To proceed, you must prepare the following:
Domain name for a
Two servers, 1 telecom network, 1 like P4, memory 2G or more
Blank DVD R+ 1 disc (or CD-R 6)
One DVD recorder (or one CD RW recorder)

Then you need to download the ISO image of CentOS
Random in the following mirror address pick 1, there is no domestic, it is recommended to hang a thunderbolt slowly

http://ftp.ncnu.edu.tw/Linux/CentOS/5.0/isos/i386/
http://ftp.cse.yzu.edu.tw/pub/CentOS/5.0/isos/i386/
http://ftp.cs.pu.edu.tw/Linux/CentOS/5.0/isos/i386/
http://ftp.tcc.edu.tw/Linux/CentOS/5.0/isos/i386/
http://mirror.mirr4u.com/centos/5.0/isos/i386/
http://mirror.tini4u.net/centos/5.0/isos/i386/
http://mirror.averse.net/centos/5.0/isos/i386/

When you open the url above, you will find a file name similar to the one below
CentOS-5.0-i386-bin-1of6.iso
...
CentOS-5.0-i386-bin-6of6.iso
These are CD images. There are 6 of them. It is a waste of resources to download the disk
CentOS-5.0-i386-bin-DVD.iso
Nonsense not to say, download back after the disk can be.

After that, an arrangement is made for the resources, so the following assumption will be made:
Assume the domain name is naizhao.com
Suppose you have two servers, A for telecom and B for netcom
Assume that the A server is the content server, the B server is the CDN server, and all the content required by the B server is obtained from the A server
Assume that IP for A server is 1.1.1.1 and IP for B server is 2.2.2.2

OK, when we get here we're almost ready for what we need. ISO may not be downloaded yet, don't worry, hang up slowly, let's first set up the DNS domain name

(to be continued)


Related articles: