Install Squid Proxy Server on CentOS / Redhat enterprise Linux 5

I've already wrote about setting up a Linux transparent squid proxy system. However I'm getting lots of questions about Squid basic installation and configuration:

How do I install Squid Proxy server on CentOS 5 Liinux server?

Sure Squid server is a popular open source GPLd proxy and web cache. It has a variety of uses, from speeding up a web server by caching repeated requests, to caching web, name server query , and other network lookups for a group of people sharing network resources. It is primarily designed to run on Linux / Unix-like systems. Squid is a high-performance proxy caching server for Web clients, supporting FTP, gopher, and HTTP data objects. Unlike traditional caching software, Squid handles all requests in a single, non-blocking, I/O-driven process. Squid keeps meta data and especially hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests. Squid consists of a main server program squid, a Domain Name System lookup program (dnsserver), a program for retrieving FTP data (ftpget), and some management and client tools.

Install Squid on CentOS / RHEL 5

Use yum command as follows:
# yum install squid
Output:

Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package squid.i386 7:2.6.STABLE6-4.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 squid                   i386       7:2.6.STABLE6-4.el5  updates           1.2 M

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)         

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: squid                        ######################### [1/1] 

Installed: squid.i386 7:2.6.STABLE6-4.el5
Complete!

Squid Basic Configuration

Squid configuration file located at /etc/squid/squid.conf. Open file using a text editor:
# vi /etc/squid/squid.conf
At least you need to define ACL (access control list) to work with squid. The defaults port is TCP 3128. Following example ACL allowing access from your local networks 192.168.1.0/24 and 192.168.2.0/24. Make sure you adapt to list your internal IP networks from where browsing should be allowed:
acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks

Save and close the file. Start squid proxy server:
# chkconfig squid on
# /etc/init.d/squid start

Output:

init_cache_dir /var/spool/squid... Starting squid: .       [  OK  ]

Verify port 3128 is open:
# netstat -tulpn | grep 3128
Output:

tcp        0      0 0.0.0.0:3128                0.0.0.0:*                   LISTEN      20653/(squid)

Open TCP port 3128

Finally make sure iptables is allowing to access squid proxy server. Just open /etc/sysconfig/iptables file:
# vi /etc/sysconfig/iptables
Append configuration:
-A RH-Firewall-1-INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp --dport 3128 -j ACCEPT
Restart iptables based firewall:
# /etc/init.d/iptables restart
Output:

Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[  OK  ]

Client configuration

Open a webbrowser > Tools > Internet option > Network settings > and setup Squid server IP address and port # 3128.

See also

You may find our previous squid tips useful:

Squid Security and blocking content Related Tips

Squid Authentication Related Tips

Squid Other Tips

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 27 comments… read them below or add one }

1 manivannanan 09.14.07 at 9:24 am

i need linux el e 5 ,how to configure cui mode in

example el 4 netconfig ip ,subnet,gateway

but same command not working in el 5 kindly send to me command

2 Pkhunter 09.17.07 at 3:02 pm

Hi,

I just need to use Squid as a cache for Apache’s requests, not for any filtering or such. Is there anyway I can set it up on CentOS?

Thanks!

3 jessica koh 10.04.07 at 3:56 pm

thanks for the tutorial.

Now, I got everything working. I am trying to browse google.com using newly configure proxy. I get the below error

“The requested URL could not be retrieved”

Access Denied.

How can I go about this? Thank you.

4 kunal 10.07.07 at 7:03 am

How to set up reverse squid proxy server2.6 on CentOS

5 Kunal 10.27.07 at 2:11 pm

how to install Squid reverse proxy2.6 on CentOS

6 kunal 12.10.07 at 12:20 pm

how to install and configure reverse squid proxy for caching images for a long time and please explain refresh_pattern of squid and how to use it in Reverse Squid Proxy.

7 shankar kumar 04.09.08 at 1:11 pm

iam shankar kumar from bangalore. i have problem in dansgaudian problem how to configure dansguardian with squid and how to block downloading and uploding and some websites i want to block

8 Ananda Bhattacharjee 06.07.08 at 6:30 am

Hello everybody,
Can any body tell me how to block or restrict web sites via squid i386 7:2.6.STABLE6-4.el5 and is it possible to enable content filtering in squid if yes please tell me the steps to.

Thanking You
Ananda Bhattacharjee.
ananda.bhattacharjee@gmail.com

9 ASP Consultant 06.23.08 at 7:38 am

how to install squid guard on centos? how to block all external ip and allow some specific one from network?

10 hasan 07.14.08 at 4:29 am

i want a brief method to install squid on CentOS 4.3 final….with trouble shooting..send me e books or physical magazine to my home address.Madina Mobiles Chowke Farooq-e-Azam Peco road link Multan road Lahore Pakistan.

11 Ritesh 07.17.08 at 11:57 am

Hi!I m Ritesh,
I just want to know what are the proceedures to configure transparent suqid proxy server.can anyone help?

12 Andy 07.26.08 at 7:27 pm

Hello, I get an error when I tried to do the command /etc/init.d/iptables restart, here was the output I received:

[root@andydaykin ~]# /etc/init.d/iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: mangle filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: iptables-restore: line 1 failed
[FAILED]

13 Rabinarayan Nayak 08.21.08 at 5:25 pm

Hello Sir,
I am rabi from orissa.first time i am installing linux and squid. plz give me details how to install and configure squid in linux server.

14 mahesh 09.12.08 at 6:39 am

Plz tell me how to install squid in red hat ver5.

15 nilay 12.10.08 at 11:08 am

hello,
red hat proxy use3128 port , is it tcp or udp port?

16 anbu 01.18.09 at 7:09 am

i need 2 block particular websites on Konqueror browser ,,,squid server working fine but Konqueror not supporing,it blocks all website instead of few web sites, pls help….

17 Madness 01.27.09 at 8:01 pm

Hi
Grand THNX for the tutorial.
But further to i´d like to use Squid as a cache for different requests, not only for filtering. How can I set it up or any URL how to do that?
Thnx

18 PrzemeQ 02.11.09 at 4:48 pm

Hi! i need patches to install this programme’s but on the squidy

19 Nitin Shende 02.17.09 at 12:24 pm

I want to block some websites . What are the configuration on Redhat Linux 4 squid file?

20 Jai prakash sukhwal 02.17.09 at 1:07 pm

Sir,
I want to run to IP in my network one for broad band and second for RF connetivity.
Please tell me what i have to do on linux server 5.0.
Plz responce me soon.
Thanks & Regards

21 satyajeet tripathi 03.07.09 at 7:38 am

sir,
I am making a squid proxy server.but a error given when i execute a command service squid start and error is
starting squid: /etc/init.d/squid: line 53: 6522.aborted $ squid_opts>>/var/log/squid/squid.out2>&1 [failed]

plz solve my problem early
Thanks & Regards

22 amit 03.19.09 at 6:33 am

I want to block some websites . What are the configuration on Redhat Linux 4 squid file?

23 Jaganathan 04.11.09 at 7:19 pm

Hello can anyone explain about squid in detail & how to configure in linux

24 ROSHAN JALNDHARA 05.01.09 at 8:48 am

plg send me sharing in internet linux&window

25 anurag 05.04.09 at 5:17 pm

when i try to start squid services i got the error
init_cache_dir /var/spool/squid… /etc/init.d/squid: line 54: 5415 Aborted $SQUID -z -F -D >>/var/log/squid/squid.out 2>&1
Starting squid: /etc/init.d/squid: line 53: 5416 Aborted $SQUID $SQUID_OPTS >>/var/log/squid/squid.out 2>&1
[FAILED]

can anyone help me out…..

26 siyolka 06.03.09 at 5:55 am

pls some one send me the full guide of Red hat enterprise Linux 5. coz i’ll try it several times but i cant manage it

27 PALANIVEL 06.22.09 at 9:15 am

MY SERVER IS RUNNING RHEL-5 .I HAVE CONFIGURED SQUID PROXY SERVER IN RHEL-5. THE DNS SERVER IP IS PINGING.AND GATEWAY ALSO PING . BUT ANY ONE DOMAIN SERVER NOT PING IN MY SERVER. THE ERROE MESSAGE IS UNKNOWN HOST http://WWW.GOOGLE.COM.
PLEASE GIVE ME THE SOLUTION

WITH REGARDS

R.PALANIVEL
CHENNAI

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , ,

Previous post: Download of the day: Linux Weather wallpaper

Next post: HP Compaq DX2250: Red Hat Linux-based Desktop Computer