This howto will show you the steps to install and configure a Squid 3 Proxy Server on CentOS6.2. Squid service plays two main roles which mainly act as a caching proxy server between the user and the web. Second role, squid also regularly used as a content accelerator, or reverse proxy, intercepting requests to a server and using a cached version of the page to serve the request. Follow below steps to install and configure squid.
1. Install Squid proxy using yum command. This installation is performed using local yum repository as documented in this article. (How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2)
[root@centos62 ~]# yum install squid -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.maulvi.net * extras: centos.maulvi.net * updates: centos.maulvi.net Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package squid.i686 7:3.1.10-1.el6_2.1 will be installed --> Processing Dependency: perl(Getopt::Long) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(integer) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(Pod::Usage) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(DBI) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(Digest::MD5) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(vars) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: libltdl.so.7 for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(strict) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: /usr/bin/perl for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(Getopt::Std) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Processing Dependency: perl(Net::POP3) for package: 7:squid-3.1.10-1.el6_2.1.i686 --> Running transaction check ---> Package libtool-ltdl.i686 0:2.2.6-15.5.el6 will be installed ---> Package perl.i686 4:5.10.1-119.el6_1.1 will be installed --> Processing Dependency: perl-libs = 4:5.10.1-119.el6_1.1 for package: 4:perl-5.10.1-119.el6_1.1.i686 --> Processing Dependency: perl-libs for package: 4:perl-5.10.1-119.el6_1.1.i686 --> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-119.el6_1.1.i686 --> Processing Dependency: libperl.so for package: 4:perl-5.10.1-119.el6_1.1.i686 --> Processing Dependency: perl(version) for package: 4:perl-5.10.1-119.el6_1.1.i686 --> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-119.el6_1.1.i686 ---> Package perl-DBI.i686 0:1.609-4.el6 will be installed --> Running transaction check ---> Package perl-Module-Pluggable.i686 1:3.90-119.el6_1.1 will be installed ---> Package perl-Pod-Simple.i686 1:3.13-119.el6_1.1 will be installed --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-119.el6_1.1.i686 ---> Package perl-libs.i686 4:5.10.1-119.el6_1.1 will be installed ---> Package perl-version.i686 3:0.77-119.el6_1.1 will be installed --> Running transaction check ---> Package perl-Pod-Escapes.i686 1:1.04-119.el6_1.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: squid i686 7:3.1.10-1.el6_2.1 updates 1.7 M Installing for dependencies: libtool-ltdl i686 2.2.6-15.5.el6 CentOS6.2-Repository 45 k perl i686 4:5.10.1-119.el6_1.1 CentOS6.2-Repository 9.7 M perl-DBI i686 1.609-4.el6 CentOS6.2-Repository 705 k perl-Module-Pluggable i686 1:3.90-119.el6_1.1 CentOS6.2-Repository 37 k perl-Pod-Escapes i686 1:1.04-119.el6_1.1 CentOS6.2-Repository 30 k perl-Pod-Simple i686 1:3.13-119.el6_1.1 CentOS6.2-Repository 209 k perl-libs i686 4:5.10.1-119.el6_1.1 CentOS6.2-Repository 590 k perl-version i686 3:0.77-119.el6_1.1 CentOS6.2-Repository 49 k Transaction Summary ==================================================================================================== Install 9 Package(s) Total download size: 13 M Installed size: 38 M Downloading Packages: (1/9): squid-3.1.10-1.el6_2.1.i686.rpm | 1.7 MB 00:14 ---------------------------------------------------------------------------------------------------- Total 881 kB/s | 13 MB 00:15 warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid : CentOS-6 Key (CentOS 6 Official Signing Key) Package: centos-release-6-2.el6.centos.7.i686 (@anaconda-CentOS-201112130233.i386/6.2) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 1:perl-Pod-Escapes-1.04-119.el6_1.1.i686 1/9 Installing : 3:perl-version-0.77-119.el6_1.1.i686 2/9 Installing : 4:perl-libs-5.10.1-119.el6_1.1.i686 3/9 Installing : 1:perl-Pod-Simple-3.13-119.el6_1.1.i686 4/9 Installing : 1:perl-Module-Pluggable-3.90-119.el6_1.1.i686 5/9 Installing : 4:perl-5.10.1-119.el6_1.1.i686 6/9 Installing : perl-DBI-1.609-4.el6.i686 7/9 Installing : libtool-ltdl-2.2.6-15.5.el6.i686 8/9 Installing : 7:squid-3.1.10-1.el6_2.1.i686 9/9 Installed: squid.i686 7:3.1.10-1.el6_2.1 Dependency Installed: libtool-ltdl.i686 0:2.2.6-15.5.el6 perl.i686 4:5.10.1-119.el6_1.1 perl-DBI.i686 0:1.609-4.el6 perl-Module-Pluggable.i686 1:3.90-119.el6_1.1 perl-Pod-Escapes.i686 1:1.04-119.el6_1.1 perl-Pod-Simple.i686 1:3.13-119.el6_1.1 perl-libs.i686 4:5.10.1-119.el6_1.1 perl-version.i686 3:0.77-119.el6_1.1 Complete!
2. Configure server hosts file :
[root@centos62 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.44 centos62.ehowstuff.com
3. Configure main squid configuration file. Use vi to edit.
[root@centos62 ~]# vi /etc/squid/squid.conf
4. Add your internal network name into the IP networks list where browsing should be allowed. In this example, your internal network name is ehowstuff.com.
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl ehowstuff.com src 192.168.1.0/24 # Your internal network
5. Add ehowstuff.com network in the ACL section list IP networks where browsing should be allowed :
#http_access allow localnet http_access allow localhost http_access allow ehowstuff.com
6. Make sure squid proxy port is uncomment. You can change the proxy port to any available port here. As an example, other available port is 8080.
# Squid normally listens to port 3128 http_port 3128
7. Configure auto start at boot for squid service :
[root@centos62 ~]# chkconfig squid on
8. Start squid service :
[root@centos62 ~]# service squid restart Stopping squid: ................ [ OK ] Starting squid: . [ OK ]
9. Client browser configuration should be as below :