Squid Foundation and Configuration

Time:2019-8-11

Introduction to Squid

1. What is Squid?

Squid is a software used to buffer Internet data. In this way, it achieves its functions by accepting requests from objects that people need to download and processing them appropriately. That is to say, if a person wants to download a web page, he asks Squid to get it for him. Squid then connects to a remote server (such as http://squid.nlanr.net/) and makes a request to this page. Then Squid explicitly aggregates data to the client machine and replicates one copy at the same time. The next time someone needs the same page, Squid can simply read it from disk, and the data will be transferred to the client in no time. Current Squid can handle HTTP, FTP, GOPHER, SSL and WAIS protocols. But it can’t handle things like POP, NNTP, Real Audio and other types of things.

2. Some Concepts of Internet Buffer

You may think of some questions: How useful is buffering? When should or should not the target be buffered? For example, buffering credit card numbers is totally inappropriate, script file execution results in remote server side, site updates (such as www.cnn.com) or even sites do not allow buffering, these situations are also inappropriate for buffering.

Squid is good for handling all kinds of situations (which, of course, requires remote sites to work in standard form).

Executable cgi-bin script files are not buffered, pages returning to the correct header are buffered within a limited period of time, and you can specify special rules to determine what can or can not be buffered, and how long the buffering time is.

When it comes to the usefulness of buffers, it depends on the size of the Internet. For small buffers (a few turns of disk space), the return value is very high (up to 25%). This space buffers frequently visited sites such as netscape, CNN and others in similar situations. If you double the buffered disk space, you won’t double your hit rate. This is because when you start buffering the rest of the network, these are usually large and rarely accessed. A very large cache, with about 20 rpm, may return less than 50% unless you change the amount of time you save data (generally you don’t allocate 20 RPM disk space, because pages will soon become obsolete and should be deleted).

The object we are talking about here refers to a saved web page or other similar downloadable page (ftp file or directory content is also called an object).

3. What system does Squid run on?

Squid runs on most Unix and OS/2 versions of systems, known to work on:

  AIX,Digital Unix,FreeBSD,HP-UX,Irix,Linux,NetBSD,Nextstep,SCO,Solaris

2. Compile and install Squid

1. Uncompiled version of Squid

I can’t guarantee that you will find all the uncompiled versions of Squid. You can find some uncompiled versions on ftp: squid. nlanr. net, although they may not be the latest version.

Squid is generally easy to compile because it can be automatically configured. The only real question is whether you have a compiler on your machine. This could happen: You bought a commercial OS but it did not include standard development options. You might consider installing a GNU compiler in this case, if you have the necessary files under / usr / include. Another option for you may be to ask for help. You may need to check “tracker database” to find someone running Squid near you. Assuming they have the right hardware, they will probably help you.

1. Before compiling

The best way to run Squid (in my opinion) is to create a specific user and group to run it. I created a Squid user and a Squid group under the same name and set the user’s home directory to / usr / local / squid. Then I Su to the Squid user, so that the files are owned by the Squid and Squid groups (the Squid user primary group must be Squid). Then I downloaded the Squid source file to / usr / local / squid / SRC and unpacked it.

This may not be the best way to install Squid on your system, but if multiple users will use squid, you can put them all in the Squid group. (Of course, if you don’t understand what I’m saying, you can install it in your own name. Don’t use root, otherwise, you’ll put your machine in danger of safety.)

2. Get the source code

The source site of Squid is squid.nlanr.net. There are many other mirror sites here, and you can consider getting it from your local mirror site or searching on the Archie server. Once you have downloaded it (usually under / usr / local / squid / src/), you can use the following commands to decompress it:
Gzip-cd squid-tar.gz-fil | tar XV or tar zxvf squid-tar.gz-fil
This will create directories similar to the following: / usr / local / squid / SRC / squid-1.1.13/(depending on the version).

3. Compiling Squid

The following are general instructions for compiling Squid. You may have to do something else to compile Squid into your system. Usually you can run a configuration script file that specifies your system settings and the title file on your machine. In this way, after decompressing and unpacking the file. CD to / usr / local / squid / SRC / squid-version / and enter:
./configure

This assumes that you are going to install Squid to / usr / local / squid. You can also modify your installation directory in the following ways:
./configure -prefix=/some/other/directory

Then you may have to type: make and enter make install if everything is compiled properly. This will generate the directory that will be described later and install the file into the directory.

3. Basic configuration of Squid

1. Directory structure

Squid usually creates several directories. They are generally as follows:
/usr/local/squid
/bin
/cache
/etc
/logs/
/ SRC (which we created earlier)
/ Bin includes Squid’s own programs, as well as other programs such as ftpget, which can be used by Squid to perform various functions.
/ The cache / directory is the storage area for the actual buffered data. You may want to consider placing the remaining buffers in different partitions, or even on different disks. It contains directories in the form of the following lines: / 00 / 01 / 02 / and / 03 / These include more subdirectories and ultimately buffered actual data. Storing data in multiple directories means that retrieving data from a large buffer is still fast, because it takes a long time for your operating system to read a directory containing 10,000 files.
/ etc / contains the squid.conf file, which is the only Squid configuration file.
/ Logs / directories can be very large, especially if you include affiliates, they will query you every connection, which can double your log files. Note that there is also a / log / file in the cache directory, but you can’t delete or move it. It is an index of the / usr / local / squid / cache / directory discussed above. (This is similar to IE cache.)
/ SRC / generally includes the source files that you run the Squid version.

2. Basic configuration

All Squid configurations are centralized into one file, squid.conf. The configuration of Squid as a buffer proxy server is discussed in detail below, not as an HTTP accelerator.

The following is a basic configuration file:
#squid.conf – a very basic config file for squid

#Turn logging to it’s lowest level
debug_options ALL,1

#defines a group (or Access Control List) that includes all IP
#addresses
acl all src 0.0.0.0/0.0.0.0

#allow all sites to use connect to us via HTTP
http_access allow all

#allow all sites to use us as a sibling
icp_access allow all

#test the following sites to check that we are connected
dns_testnames internic.net usc.edu cs.colorado.edu mit.edu yale.edu

#run as the squid user
cache_effective_user squid squid
#otherwise, you can uncomment the below line and comment the one out.
# this will run as use “nobody” with the group “nogrtoup”
cache_effective_user nobody nogroup

This configuration allows everyone to access the buffer and create a 100M buffer, using 8M memory, keeping the minimum logs, and storing all files to the default area. This generally means that all files will be stored in the name of Squid users and Squid groups in “/usr/local/squid/cache”. All customer requests will come from port 3128, and all inter-cache traffic will go to UDP port 3130. Note that this configuration file allows everyone to access your buffer machine, which may not be what you want, but at least it works.

3. Running Squid

Squid runs normally by a script that restarts Squid after its process dies. There are two versions of the script: / usr / local / squid / bin / RunCache and / usr / local / squid / bin / RunAccel.
RunCache scripts generally run in the foreground, so start Squid and enter the following:
% /usr/local/squid/bin/RunCache& %
Then use the following command to view the main Squid log file / usr / local / squid / logs / cache.log
% more /usr/local/squid/logs/cache.log

You will see information about Squid startup as follows:
97/02/24 19:34:52| Starting Squid Cache version 1.1.10 for i586-pc-linux-gnu…
97/02/24 19:34:52| With 256 file descriptors available
97/02/24 19:34:52| Initializing IP Cache…
If you don’t see any information about FATAL errors, Squid can now run happily on your machine.

Next will configure your browser, you can try it well!

4. Basic configuration of client software

The following are basic configurations for browsers:

Netscape (version 4.5 or more):
Select the Preferences item from the Edit menu item. On the Proxies page in Advanced, click the button to enter the Proxy configuration manual, and then click the View button. For each protocol item supported by your Squid server (default HTTP, FTP, gopher, etc.), fill in the host name or IP address of the Squid server, and fill in the HTTP port number of the Squid server (default is 328) in the portbar. For agreements that are not supported by your Squid, you can leave these columns blank.

IE (Chinese version above 5.0):
Select the Internet option in the tool menu item, then click on the connection page, and then press the LAN settings button to select the proxy server option to enter the advanced project editing. Then you can see that the Netscape proxy server set up a similar interface and fill in the corresponding items according to the method described above.

General Unix configuration:

If you use Unix programs that allow you to access the web (including wget, lynx, mosaic, etc.), you can set shell variables through which proxies can be configured.

If the shell you use is tcsh or csh, the commands are as follows:
% setenv http_proxy http://mycache.example.com:3128/
% setenv gopher_proxy http://mycache.example.com:3128/
% setenv ftp_proxy http://mycache.example.com:3128/

Now you can use your browser and buffer connection to download the page. To check whether the buffer works properly, you can view the contents of the / usr / local / squid / logs / access. log file with the following commands: more / usr / local / squid / logs / access. log. You can see that all your access information is displayed in this file.