Build your own CDN of 8 with DNSPod and Squid and test and run SQUID
- 2020-05-06 12:11:21
- OfStack
1. Prepare
To test whether SQUID works, you must first resolve the www.naizhao.com domain name to the IP domain name of 2.2.2.2. As in the previous chapter, if you are a netcom user, you do not need to do anything. DNSPod will return you the IP of 2.2.2.2. If you are a telecom user, or the IP is not 2.2.2.2, then you need to modify the hosts table of the system and add the corresponding records. Unlike the previous chapter, which modified the hosts table of the SQUID server, you now need to modify the hosts table of the system you used to test SQUID.
In addition to modifying the hosts table, we need a small tool called curl. General Linux/Unix systems come with this tool, if you use Windows, you need to download one at the following address and put it in D (or wherever you like).
http: / / curl. haxx. se/latest cgi? curl= win 32-nossl (32-bit system)
http: / / curl. haxx. se/latest cgi? curl= win64-nossl (64-bit system)
After downloading and unzipping, we only need an curl.exe.
2. Run SQUID
We continue with the methods in the previous chapter, starting SQUID
in debug modecd usr/local/SQUID/sbin
. /
SQUID Nd - 1Then open the browser, input http: / / www naizhao. com, look at the output page is correct.
If a normal page appears, then SQUID is up and running. But we also need to make sure that the required pages have been cached by SQUID.
3. Test SQUID
Using curl, type the following command (Windows user please use the command line to run curl)
curl - I http: / / www naizhao. com/
200 OK
HTTP / 1.0Date: Sun, 08 Jul 2007 12:16:27 GMT
Server: NaiZhao Web Server / 1.0.0
Es149en-Modified: Wed, 13 Dec 2006 06:11:14 GMT
Es160en480 b ETag: "7665-1983-4417"
Accept - Ranges: bytes
Es174en Content - Length: 6531
Vary: Accept - Encoding
Content - Type: text/css
Es194en Age: 29155
X - Cache: MISS from cnc. naizhao. com
Via: 1.0 cnc naizhao. com: 80 (SQUID / 2.6 STABLE13)
Connection: close
We notice the output, and the following line indicates that the cache was not hit. That is, the required file is not read from the cache. It is normal for MISS to appear the first time a file is accessed, because the file does not exist in the cache to begin with.
X - Cache: MISS from cnc. naizhao. com
Then, we run the command again and continue to see the output
curl - I http: / / www naizhao. com/
200 OK
HTTP / 1.0Date: Sun, 08 Jul 2007 12:16:27 GMT
Server: NaiZhao Web Server / 1.0.0
Es277en-Modified: Wed, 13 Dec 2006 06:11:14 GMT
Es288en480 b ETag: "7665-1983-4417"
Accept - Ranges: bytes
Es302en Content - Length: 6531
Vary: Accept - Encoding
Content - Type: text/css
Es322en Age: 29155
X - Cache: HIT from cnc. naizhao. com
Via: 1.0 cnc naizhao. com: 80 (SQUID / 2.6 STABLE13)
Connection: close
As you can see, this time the output is HIT. That is, the content is read from the cache.
If the second access is still MISS, you should check to see if the page is cached. You can start with the following:
Es363en-Modified: Wed, 13 Dec 2006 06:11:14 GMT checks whether the line changes with each visit. If it keeps changing, the page is dynamic and is not suitable for the SQUID cache. SQUID checks this line with each request to see if the page has expired and to retrieve the expired page.
Es374en-Control: no-store, no-cache, must-revalidate, post-check =0, pre-check =0 this line is responsible for controlling the cache. Es386en-store, no-cache, must-revalidate, etc., all require SQUID to disable caching and verify that the page is out of date on every request.
If the Expires: Thu, 19 Nov 1981 08:52:00 GMT expiration time is greater than the current time, it is also considered the page has expired and needs to be retrieved. Such pages are not cached.
Pragma: no-cache is also not allowed to cache.
We can according to the above content for self-examination and correction, according to the actual needs of the site can be modified.
After making sure there are no problems, we can make SQUID officially run.
4. Official operation of SQUID
ulimit
Hs in 65536ulimit
n in 65536. / SQUID
Just use the command above to get SQUID running.
Run after input http: / / www naizhao. com see if access to normal.
5. Have SQUID follow the system to start
CentOS getting SQUID to start with the system is simple. You just need to edit /etc/ rc.local and add the following at the end
ulimit
Hs in 65536ulimit
n in 65536/ usr/local/SQUID/sbin/SQUID