Detailed instructions on using the proxy server Squid

Source: Internet
Author: User
Article Title: detailed explanation of the use of the proxy server Squid. 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.
As the most popular operating system, Linux has become increasingly popular. Although Linux software is not rich yet, it is too early to replace WINDOWS as an ordinary PC operating system, but in the server field, the stability and operability of Linux will never be lost in any operating system, it also provides excellent software support. Squid is one of them. Linux's combination of Squid and Squid serves as a proxy server, with far higher performance than WINNT's and MSPROXY2.0 (personal opinion), and more than enough for a few hundred small LAN agents. Next, I will introduce the installation and usage of Squid in detail. I hope you will like it.
  
1. Squid Introduction
  
Squid is a software used to cache internet data. It receives user download requests and automatically processes the downloaded data. That is to say, when a user wants to download a home page, it sends an application to Squid to download it for it, and then Squid connects to the requested website and requests the home page, the home page is sent to the user and a backup is retained at the same time. When other users apply for the same page, Squid immediately transmits the saved backup to the user, making the user feel that the speed is quite fast. Currently, Squid can act as the proxy for HTTP, FTP, GOPHER, SSL, and WAIS protocols. Currently, it cannot act as the proxy for POP, NNTP, and other protocols. However, someone has begun to modify Squid. I believe that Squid will be able to proxy these protocols in the near future.
  
Can Squid cache any data? No. Such as cached credit card accounts, scripts that can be executed remotely, and frequent homepage changes are inappropriate and insecure. Squid can be automatically processed. You can also set Squid based on your needs to filter out what 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, many others have re-compiled Squid in other operating systems.
  
Squid's requirement on hardware is that the memory must be large and should not be less than 128 M. The faster the hard disk speed, the better. It is best to use the dedicated server SCSI hard disk, the less demanding processor, more than MH can be used.
  
2. Squid compilation and running
  
In fact, the current Linux release kit basically has compiled Squid. What you do is to install it. If you do not have a compiled Squid or want to use the latest version, download it from ftp: squid.nlanr.net and compile it by yourself.
  
Squid compilation is very simple, because it basically configures itself. The most common problem is that your system does not have a suitable compiler, which can be solved by installing the appropriate compiler. If you have other questions, you can ask experienced users or contact the corresponding email list for help.
  
Before compiling Squid, it is best to create a user and group dedicated to running Squid. I created a user and group named squid on my server, and set the user directory to/usr/local/squid. Then, su downloads the squid source file from squid.nlanr.net to the/usr/local/Squid/src directory. Run the following command to decompress the file:
  
% 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 /. Command./configure will automatically query your system configuration and the header files used in your system. Without parameters. /configure installs Squid in the/usr/local/squid directory. If you want to use other directories, run the following command. /configure -- prefix =/some/other/directory. This will install Squid in the/some/other/directory. Make command to compile Squid, make install command to install Squid.
  
The following directory appears in the directory/usr/local/squid:
  
/Bin
  
/Cache
  
/Etc
  
/Logs/
  
/Src (self-created)
  
The/bin directory contains Squid executable programs, including Squid itself and ftpget.
  
Directory/cache contains Squid cached data, including directories such as/00/01/02/AND/03/. These directories also contain subdirectories, because directories are much easier and faster than searching for one file among thousands of files in a directory.
  
The/etc directory contains the unique configuration file Squid. conf of squid.
  
The/logs directory contains Squid logs.
  
  
3. Configure the squid. conf file
  
After Squid is installed, a sample squid is automatically generated in the directory/usr/local/squid/etc. conf file. Each option in the file is described in detail. You can modify the file to meet different needs.
  
In general, there are several important options:
  
? Http_port: Set the port for the Squid listener. You 'd better set a well-remembered port number so that it is easy to remember When configuring the client. The port number on my machine is 8080. The default value is 3128.
  
? Cache_mem: Set the physical memory occupied by Squid. Based on my experience, the size of cache_mem should not exceed 1/3 of the physical memory of your server. Otherwise, the overall performance of the machine will be affected.
  
? Maximum_object_size: set the maximum object size that Squid can receive. The default value of Squid is 4 M. I think it is too large for entry. You can set it based on your needs.
  
? Cache_dir: Set the cache location and size. The general format is as follows: "cache_dir/usr/local/squid/cache 100 16 256 ". /Usr/local/squid/cache represents the cache location; 100 represents the maximum cache size of 100 MB; 16 and 256 represent the number of level-1 and level-2 directories.
  
? Cache_effective_user: sets the valid users who use the cache. The default value is user nobody. If there is no user nobody in your system, it is best to create one or run Squid as a non-root user.
  
Below is a simple squid. conf 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 des all IP addresses
  
Acl all src 0.0.0.0/0.0.0.0
  
# Define RAM used
  
Cache_mem 32 M
  
# 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_inclutive_user squid
  
This configuration file allows everyone to use Squid, create a m cache, use 32 M memory, and cache data in the default location "/usr/local/squid/cache, all cached data is saved as a group squid and user squid. The port is 3128. Although this configuration is not safe, it can be used.
  
  
4. Run Squid
  
First, log in as root. Run the following command:
  
%/Usr/local/squid/bin/squid? Z
  
This command will generate all the cache directories of Squid.
  
If you want to run Squid on the front-end, run the following command:
  
%/Usr/local/squid/bin/squid-NCd1
  
This command officially starts Squid. If everything is normal, you will see a line of output
  
Ready to serve requests.
  
If you want to run Squid in the background and use it as an genie process, run the following command:
  
%/Usr/local/squid/bin/squid
  
Check whether Squid runs the command:
  
% Squid-k check
  
The output will tell you the current status of Squid.
  
Well, the article will write it here first. In fact, this article describes the most basic things. Squid has many advanced functions, such as high-speed cache for WEB servers, second-level proxy servers, and firewalls, and how to set filtering rules. I will not go into detail here. If you have the opportunity, I will give it to you.
  
   
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.