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:

ADVERTISEMENTS

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
65 comments… add one
  • manivannanan Sep 14, 2007 @ 9:24

    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

  • Pkhunter Sep 17, 2007 @ 15:02

    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!

  • jessica koh Oct 4, 2007 @ 15:56

    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.

    • Abdur Rob Mian May 12, 2010 @ 3:57
      # yum install squid
      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!
      
      # 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:
      tcp        0      0 0.0.0.0:3128                0.0.0.0:*
      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  ]
      • Aditya Jun 18, 2011 @ 5:17

        “-A RH-Firewall-1-INPUT -m state –state NEW,ESTABLISHED,RELATED -m tcp -p tcp –dport 3128 -j ACCEPT ”

        I appended this to last of Iptables before COMMIT but when restarting iptables giving error on line 18( same line no. where I entered above lines

        Please suggest

      • Eden Mar 6, 2014 @ 9:24

        I got the message stating that there’s no package available for squirrelmail.How will I resolve it?

  • kunal Oct 7, 2007 @ 7:03

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

  • Kunal Oct 27, 2007 @ 14:11

    how to install Squid reverse proxy2.6 on CentOS

  • kunal Dec 10, 2007 @ 12:20

    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.

  • shankar kumar Apr 9, 2008 @ 13:11

    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

  • Ananda Bhattacharjee Jun 7, 2008 @ 6:30

    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

  • ASP Consultant Jun 23, 2008 @ 7:38

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

  • hasan Jul 14, 2008 @ 4:29

    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.

  • Ritesh Jul 17, 2008 @ 11:57

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

  • Andy Jul 26, 2008 @ 19:27

    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]

    • galleline Jan 5, 2011 @ 9:23

      same problem here

      • Mohamed Aug 31, 2013 @ 0:40

        same problem, did you manage to solve this problem?

    • Chris Mar 26, 2014 @ 17:36

      The writer failed to mention that you need to establish the firewall filter. Add this line directly beneath :OUTPUT ACCEPT [0:0]

      :RH-Firewall-1-INPUT – [0:0]

  • Rabinarayan Nayak Aug 21, 2008 @ 17:25

    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.

  • mahesh Sep 12, 2008 @ 6:39

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

  • nilay Dec 10, 2008 @ 11:08

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

    • M.AMJAD Jul 21, 2013 @ 8:18

      for squid it can be use as a tcp as will as udp,
      for other apps its a tcp.

  • anbu Jan 18, 2009 @ 7:09

    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….

  • Madness Jan 27, 2009 @ 20:01

    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

  • PrzemeQ Feb 11, 2009 @ 16:48

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

  • Nitin Shende Feb 17, 2009 @ 12:24

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

  • Jai prakash sukhwal Feb 17, 2009 @ 13:07

    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

  • satyajeet tripathi Mar 7, 2009 @ 7:38

    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

    • Sathish Dec 9, 2011 @ 6:08

      Hello
      Check permissions on cache directory. The premissions should be read and write

  • amit Mar 19, 2009 @ 6:33

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

  • Jaganathan Apr 11, 2009 @ 19:19

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

  • ROSHAN JALNDHARA May 1, 2009 @ 8:48

    plg send me sharing in internet linux&window

  • anurag May 4, 2009 @ 17:17

    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…..

    • master May 4, 2010 @ 4:13

      your visible_hostname ????

  • siyolka Jun 3, 2009 @ 5:55

    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

  • PALANIVEL Jun 22, 2009 @ 9:15

    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

  • Suprobhat Sep 4, 2009 @ 10:24

    This method really workable….I had done by this and its working properly….

  • rajesh Sep 25, 2009 @ 5:20

    i install all redhat 5 series cds
    what is the next setup of install squid proxy server
    i required some sites are denayed

  • Ownvels Oct 2, 2009 @ 4:54

    Small Mistake Then (55) line missing
    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
    http_access allow all
    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.

  • Rohan Rote Nov 3, 2009 @ 11:33

    I have configured a squid server in the college. The client nodes are also configured in rhel 5. But they are facing problem while logging in with gmail and yahoo. But at the same time the windows clients are accessing gmail as well as yahoo. Is there any problem with the Mozilla 3 beta 5 version or is there any other problem ? Please help me to solve this problem.

  • ranjitdo Nov 15, 2009 @ 20:22

    how can i activate squid for 5 ips i have ?

  • www.udiniqgeek.com Dec 12, 2009 @ 7:28

    Sir,

    Thank for this tutorial … its very2 good . Good Luck !

  • Ravi Jan 23, 2010 @ 5:56

    i wanna know how to configure the proxy server on linux os?

  • Ravi Gowda Jan 28, 2010 @ 8:51

    how to configure dhcp server in centos linux…

  • Tefi Feb 28, 2010 @ 19:49

    Sir ,
    I wanna know how to configure Squidguard 1.2 in redhat el5 ?

  • Ferdaus Mar 25, 2010 @ 11:04

    I am Ferdaus. I want to know why IP Tables do not save.

  • zjhack Apr 8, 2010 @ 17:13

    hi im zjhack and im using centos5. i wonder how to use squid for site restriction. i want to restrict some site and allow only the sites that my cousin can use to their studies..

    pls help me thx
    zjhack

  • Sandeep Hegde Apr 17, 2010 @ 12:49

    How about solving this error?

    Error: the proxy server (Squid) is not configured to allow SSL tunnel to port 80.
    To fix the problem please find and comment the following line in the Squid
    configuration file (squid.conf):
    http_access deny CONNECT !SSL_ports

  • wasim May 1, 2010 @ 7:05

    hi
    i want learn more squid proxy server.
    i want learn how to install squid.
    and how to work on them

  • amirthalingam Aug 6, 2010 @ 7:50

    hi
    i want step by step configuration of squid proxy server in redhat linux 5.

  • gani Oct 30, 2010 @ 7:42

    This command did not work and I was unable to view even http://www.google.com also.
    [root@sys1 ~]# service iptables restart
    Applying iptables firewall rules: iptables-restore: line 1 failed
    [FAILED]
    [root@sys1 ~]# cat /etc/sysconfig/iptables
    -A RH-Firewall-1-INPUT -m state –state NEW,ESTABLISHED,RELATED -m tcp -p tcp –dport 3128 -j ACCEPT
    [root@sys1 ~]#

    What shoud I do now??

  • mahesh Mar 3, 2011 @ 11:49

    i cont intall squid my system.. wat is the main problem….

  • swafoman Mar 22, 2011 @ 1:28

    Thank you so much for such a clear and simple set of instructions.
    This REALLY made my day.
    Got it all installed and up and running in no time.

    Thanks.

  • chetan Mar 28, 2011 @ 7:14

    thank you so much,,,,,,,,,,,,

    for give easy ways of understanding,,,,,,,,,,,,,,,,,,,,,

  • vinod Apr 19, 2011 @ 7:25

    how to block some site in our network with the help of squid.
    how to put webaddress in squid.conf ?
    how to give special host permission for some machine for login gmail.com ?
    can u help me

  • Prashant May 16, 2011 @ 12:39

    Hello,

    I have installed Squid Proxy server( as per the procedure given on your website) for internet access in our LAN. But after configuring IE for using proxy server, the users are not able to get access to Internal SAP Servers. Tried with option “Bypass Proxy for local ..” but didnt work.
    Can anyone help?

  • sunil Jul 7, 2011 @ 6:11

    hello sir
    can please help me i have one public ip address i want share in different private ip in redhat 5.0 linux how i do it please help me and also i block some websit
    my public ip is 210.212.11.130 and my private ip is 192.168.2.1-192.168.2.200
    please tell me how i config dhcp,and squid

  • Imran Haider Sep 5, 2011 @ 10:25

    how to block particular site on squid server like facebook. All site should open by squid in network but not facebook

  • Techno Sep 6, 2011 @ 7:38

    Just finished installing squid on my VPS. Thanks for the post.

  • jose Nov 24, 2011 @ 17:46

    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]

  • Rakesh chaudhary Jul 12, 2012 @ 5:40

    This is very nice site, i tryted last 15 days to configure transparent proxy but not created than i will read this side finalally i create transparent proxy in Redhat linux 5
    so i again thank u for this web site.

  • Jacques Mar 31, 2013 @ 11:14

    TIP: I create a proxy on my home network behind the firewall listening on localhost:3128. And then I punch a hole through the firewall remotely using ssh to connect to the proxy when I’m away and need to connect to geolocation blocked services.

    ssh -L 3128:localhost:3128 my.home.network.org
    

    Then I setup my proxy on my lappie to point to localhost:3128 and voila!

  • vivek Oct 24, 2013 @ 9:37

    Hi Vivek,

    Can u help me to block https (443) in transparent squid proxy in 3.2.7
    Basically i need to block facebook.im using centos

  • ronnie Apr 29, 2014 @ 9:30

    when i try restarting squid it gives me this error please help

    root@localhost STUDENT1]# /etc/init.d/squid restart
    Stopping squid: 2014/04/29 02:26:36| WARNING: Netmasks are deprecated. Please use CIDR masks instead.
    2014/04/29 02:26:36| WARNING: IPv4 netmasks are particularly nasty when used to compare IPv6 to IPv4 ranges.
    2014/04/29 02:26:36| WARNING: For now we will assume you meant to write /0
    ……………. [ OK ]
    Starting squid: . [ OK ]

  • Mandar Jan 7, 2015 @ 11:30

    I faced following error after I installed squid as per the guide:

    WARNING: Could not determine this machines public hostname. Please configure one or set ‘visible_hostname’.

    To resolve it, just mention your hostname in front of ‘visible_hostname’ in the ‘squid.conf’ file and everything will work perfectly.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.