Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Squid

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use Squid". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to 1.Squid

Squid is a software that caches internet data. It receives download requests from users and automatically processes the downloaded data. In other words, when a user seems to download a home page, it sends an application to Squid, asking Squid to download it for it, then Squid connects to the applied website and requests the home page, and then sends the home page to the user while keeping a backup. When other users apply for the same page, Squid immediately sends the saved backup to the user, which makes the user feel quite fast. At present, Squid can proxy HTTP, FTP, GOPHER, SSL and WAIS protocols, but not POP, NNTP and other protocols. However, some people have begun to modify Squid, and it is believed that Squid will be able to represent these protocols in the near future.

Can Squid cache any data? No. Things like caching credit card accounts, scripts that can be executed remotely, and frequently changing home pages are inappropriate and insecure. Squid can be processed automatically, or you can set up Squid according to your needs to filter out things you don't want.

Squid can work in many operating systems, such as AIX, Digital Unix, FreeBSD, HP-UX, Irix, Linux, NetBSD, Nextstep, SCO, Solaris,OS/2, etc., and many people have recompiled Squid in other operating systems.

Squid hardware requirements is that the memory must be large, should not be less than 128m, the faster the speed of the hard disk, the better, it is best to use the server-specific SCSI hard disk, the processor requirements are not high, 400MH or above.

2. Compile and run Squid

In fact, most of the current Linux distributions have compiled Squid, and all you have to do is install it. If you don't have a ready-made compiled Squid or want to use the latest version, go to ftp:squid.nlanr.net to download one and compile it yourself.

The compilation of Squid is very simple because it basically configures itself. The most common problem is that there is no suitable compiler on your system, which can be solved by installing the appropriate compiler. If there are other questions, you can ask experienced users or go to the appropriate mailing list for help.

Before compiling Squid, it's a good idea to set up a user and group that specifically runs Squid. I set up a user and group named squid on my server, with the user directory set to / usr/local/squid. Then su squid for the user and download the source file of Squid from squid.nlanr.net to the directory / usr/local/squid/src, and extract it with the following command:

% tar xzf squid-2.0.RELEASE-src.tar.gz

% cd / usr/local/squid/src/ squid-*.*.RELEASE /

%. / configure

% make

% make install

The first command generates a new subdirectory / squid-*.*.RELEASE/ in the directory / usr/local/squid/src. The command. / configure will automatically query your system configuration and the header files used in your system. The unparameterized. / configure will install Squid in the directory / usr/local/squid. If you want to use another directory, use the following command. / configure-- prefix=/some/other/directory, which will install Squid in the directory / some/other/directory. The make command compiles Squid,make install commands to install Squid.

If nothing happens, the following directory appears in the directory / usr/local/squid:

/ bin

/ cache

/ etc

/ logs/

/ src (created by yourself)

The directory / bin contains Squid executable programs, including Squid itself, ftpget, etc.

The directory / cache contains Squid cached data, including directories like / 00 / / 01 / / 02 / and / 03 /, and there are subdirectories because it is easier and faster to find a file among thousands of files in a directory.

The directory / etc contains the unique configuration file squid.conf for Squid.

The directory / logs contains logs for Squid.

3. Configuration of squid.conf files

After installing Squid, a sample squid.conf file is automatically generated in the directory / usr/local/squid / etc, each option is described in detail, and users can modify the file to meet different needs.

In general, there are several important options:

? Http_port: set the port of the Squid****. You'd better set a port number that is easy to remember so that it is easy to remember when configuring the client. The port number on my machine is 8080. The default is 3128.

? Cache_mem: set the physical memory consumed by Squid. In my experience, the size of cache_mem should not exceed 1/3 of your server's physical memory, otherwise it will affect the overall performance of the machine.

? Maximum_object_size: sets the size of the largest object that Squid can receive. The default value of Squid is 4m, which I think is too large. You can set it according to your own needs.

? Cache_dir: sets the location and size of the cache. It generally looks like "cache_dir / usr/local/squid/cache 10016256". / usr/local/squid/cache represents the location of the cache; 100 represents the maximum cache size of 100m; 16 and 256 represents the number of primary and secondary directories.

? Cache_effective_user: sets a valid user to use the cache. The default is user nobody, and if you don't have a user nobody in your system, it's best to build one or run Squid as a non-root user.

Let me give you the simplest squid.conf file:

# squid.conf-a very basic config file for squid

# Turn logging to its 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

# define RAM used

Cache_mem 32M

# defines the cache size

Cache_dir / usr/local/squid/cache 100 16 256

# 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

This configuration file allows everyone to use Squid, creates a 100m cache, uses 32m memory, caches data at the default location "/ usr/local/squid/cache", and saves all cached data as group squid and user squid on port 3128. Although this configuration is not secure, it is already working.

4. Run Squid

First log in as root. Run the following command:

% / usr/local/squid/bin/squid? Z

This command produces all the cache directories of Squid.

If you want to execute Squid at the foreground, then execute the command:

% / usr/local/squid/bin/squid-NCd1

This command officially starts Squid. If everything is all right, you will see a line of output

Ready to serve requests.

If you want to run Squid in the background, think of it as a wizard process and execute the command:

% / usr/local/squid/bin/squid

Observe whether Squid runs the use command:

% squid-k check

The output will tell you the current status of Squid.

This is the end of "how to use Squid". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report