Article Title: using Squid in Linux to build a high-speed ProxyServer. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. What is Proxy Server? The role of Proxy
In the real world, we often help people to do things, such as pay for electricity or something. In this case, you are not the electricity meter owner, but the agent identity. In the online world, Proxy is equivalent to the person who pays for electricity. When we send a connection request, Proxy will help us directly communicate with the target server, help us obtain information.
The steps for the client to access the Internet through the Proxy Server are as follows:
① The client sends a request to the Server.
② After receiving the request, the Server compares and judges that there is information the client wants in the Cache. If not, the Server sends a data request to the remote Server.
③ Store the requested data in the Cache and then send the data to the client.
④ When the required data in the request sent by the client is in the Cache, the data in the Cache is directly sent to the client.
Although the data Cache requested from the Proxy is not in the first access, the Proxy will first save the data in the Cache after capturing the data, which slows down the access speed, however, when the second and later visitors need this information, the proxy does not want to remotely request the server and directly sends the information in the cache to the later requestor, this reduces the traffic to connect to the remote server. In addition, because the proxy is local, the transmission speed is faster.
2. Use Squid to build Proxy Server
The environment used by the author in this article is:
Operating System: Redhat 9.0, kernel: 2.4.20-31.9, other system suites have been updated to the latest through apt.
1. Compile and install Squid
Because Squid has high requirements on system hardware, we should try our best to optimize it during installation.
CODE: # groupadd squid # useradd squid add suqid user and user group
CODE: # export CFLAGES = '-O2-mcpu = pentium4-march = pentium4-mmmx-msse-msse2'
You can select the corresponding parameter GCC-3.1 based on your CPU above can ??? PU optimization:
CODE:Pentium2: -O2 -mcpu=i686 -march=i686 -mmmx Pentium3: -O2 -mcpu=pentium3 -march=pentium3 -mmmx -msse Pentium4: -O2 -mcpu=pentium4 -march=pentium4 -mmmx -msse -msse2 #./configure --prefix=/usr/local/squid --enable-gnuregex --enable-async-io=80 --enable-icmp --enable-kill-parent-hack --enable-snmp --disable-ident-lookups --enable-cahce-digests --enable-arp-acl --enable-err-language="Simplify_Chinese" --enable-default-err-languages="Simplify_Chinese" --enable-poll --enable-linux-netfilter --enable-underscore #make #make install |
I personally prefer to use the source code package to compile the software. I feel that you know what you are doing, and the rpm package seems to have been installed without knowing what you are doing. Next we will explain each compilation parameter. Of course, you can use./configure -- help to view other parameters and explain each parameter in English.
Prefix =/usr/local/squid: Specify the software installation path enable-gnuregex: Because Squid uses a large number of strings for various judgments, this item can be used for better processing.
[1] [2] Next page