How to Setup Squid Proxy in Ubuntu Server 14.04

How to Setup Squid Proxy in UbuntuSquid is a proxy server that provide cache services to the clients. It redirects client requests from web browsers to the proxy server and delivers the client’s requests and keeps a copy of them in the proxy hard disk cache. This will speeding up internet access especially for frequently-used files and reduces internet bandwidth. Squid program does not requires intensive CPU usage. To increase efficiency, i would recommend to buy faster disks or add more memory into the squid proxy server. This post describes basic steps on how to Setup Squid Proxy in Ubuntu Server 14.04.

How to Setup Squid Proxy in Ubuntu



How to Setup Squid Proxy in Ubuntu

1. Install Squid 3 :

ehowstuff@ubuntu14:~$ sudo apt-get install squid3 -y

2. Configure common setting :

ehowstuff@ubuntu14:~$ sudo vi /etc/squid3/squid.conf

Around line 919, define allowed LAN segment :

acl lan_ehowstuff src

Around line 1058, allow defined LAN :

http_access allow lan_ehowstuff

Listen on port 3128 :

# Squid normally listens to port 3128
http_port 3128

Save the configuration

See also  How to Change Hostname on Ubuntu 11.10

3. Configure Squid Proxy Authentication using digest authentication scheme :

a. Install the program ‘htdigest’ :

ehowstuff@ubuntu14:~$ sudo apt-get install apache2-utils -y

b. Setting up user :

sudo htdigest -c /etc/squid3/passwords realm_name user_name

Example :

ehowstuff@ubuntu14:~$ sudo htdigest -c /etc/squid3/passwords proxy proxyuser1
Adding password for proxyuser1 in realm proxy.
New password:
Re-type new password:

c. At line 335-337, add digest squid authentication configuration. Please note that the file digest_pw_auth has been renamed to digest_file_auth in ubuntu 14.04. By default, the digest authentication scheme is not used unless the program is specified.

auth_param digest program /usr/lib/squid3/digest_file_auth -c /etc/squid3/passwords
auth_param digest realm proxy
acl authenticated_ehowstuff proxy_auth REQUIRED
http_access allow authenticated_ehowstuff

4. Restart the Squid to take affect the new configuration :

ehowstuff@ubuntu14:~$ sudo initctl restart squid3
squid3 start/running, process 2185


ehowstuff@ubuntu14:~$ sudo service squid3 restart

5. Verify port 3128 are listening :

ehowstuff@ubuntu14:~$ sudo netstat -plunt | grep 3128
tcp6       0      0 :::3128                 :::*                    LISTEN      2185/squid3

6. Configure at client browser :
How to Setup Squid Proxy in Ubuntu

See also  How to Configure TCP keepalive Settings on Ubuntu (and other Debian-based systems)

7. Everytime you open the browser, proxy authentication box will be prompted :
How to Setup Squid Proxy in Ubuntu

8. Monitor the access log from proxy server. You can see proxyuser1 as authenticated user :

ehowstuff@ubuntu14:~$ sudo tail -f /var/log/squid3/access.log
RECT/ text/html
1409354804.372   1073 TCP_MISS/200 776 GET proxyuser1 HIER_DIRECT/ text/xml
1409354842.754    963 TCP_MISS/200 2285 POST proxyuser1 HIER_DIRECT/ application/ocsp-response
1409354843.234   1489 TCP_MISS/200 915 POST proxyuser1 HIER_DIRECT/ application/ocsp-response
1409354843.454   1549 TCP_MISS/200 2285 POST proxyuser1 HIER_DIRECT/ application/ocsp-response
1409354848.074   3249 TCP_MISS_ABORTED/000 0 POST proxyuser1 HIER_NONE/- -
1409354848.877   3248 TCP_MISS_ABORTED/000 0 POST proxyuser1 HIER_DIRECT/ -
1409354853.997   1120 TCP_MISS/200 794 GET;_ylu=X3oDMTQ0aHJqM2NuBGNjb2RlA2hvbWVydW4yBGNwb3MDMARnAzAyMTMtMGExNGQ5Zjc1NWZkZGUyYTY5M2E0ZmViNzE0MDUwOTctMDAxNARpbnRsA215BHBrZ3QDNARwb3MDMgRzZWMDdGQtb2ZsLWIEc2xrA3RpdGxlBHRlc3QDNjg0BHdvZQM5MTc5OTMzMg--/RV=1/RE=1410564437/RH=aHNyZC55YWhvby5jb20-/RO=2/RU=aHR0cHM6Ly9teS5zcG9ydHMueWFob28uY29tL2ZhbnRhc3kvc29jY2VyL3ByZW1pZXItbGVhZ3Vl/RS=%5EADA7H0JFo.Ud2RQRqK4zKbm5QoTGVg- proxyuser1 HIER_DIRECT/ text/html
1409354854.482    280 TCP_MISS/200 446 GET proxyuser1 HIER_DIRECT/ text/html
1409354854.750    549 TCP_MISS/200 4214 GET proxyuser1 HIER_DIRECT/ text/xml

I hope that above guidelines on how to Setup Squid Proxy in Ubuntu Server will help system administrator to start installing their own proxy server.



  • Avatar Muhammed Sathar says:

    I am setting up an http proxy server on AWS for the users to bypass the blocked urls by our ISP, so the users might access from remotely with different local subnets. basicaly i want to give the access from all source and enabling authentication such as username and password to authenticate with the proxy server. I am using 14.04ubuntu and installed squid, but i am unable to achieve this (i am just a newbie on this ubuntu side) so can you please help me with the scripts if you have some time.

    • Avatar Muhammed Sathar says:

      Hello Skytech, Can you please help me on the above?

      • Avatar skytech says:


        Sorry for late reply. I have updated the post above to use Squid Proxy Authentication using digest authentication. Let me know if you need any other help…

        Hope this helps.

        • Avatar Muhammed Sathar says:

          Great.. thanks a lot.. let me work on this and i will post you the feedback 🙂

          • Avatar Muhammed Sathar says:

            Hi Skytech, Its working fine now.. The auth also works great.. but a quick question what if i want to create multiple users, I think by default it only accept one user at a time. which means I have several users and who required separate user name and passwords, but when i created those and it accept only the last user which created. my server actually hosted in AWS and the purpose is actually that in our region some websites are been blocked and those who need unrestricted access, their traffic will go through this proxy.

            and this is what my squid conf. so is there anything else i need to add on this to create more users.

            Really appreciated your support.

            auth_param digest program /usr/lib/squid3/digest_file_auth -c /etc/squid3/passw$
            auth_param digest realm ibt
            acl authenticated_all proxy_auth REQUIRED
            http_access allow authenticated_all
            acl all src all
            acl SSL_ports port 443
            acl CONNECT method CONNECT
            http_access allow all
            http_port 9999
            hierarchy_stoplist cgi-bin ?
            coredump_dir /var/spool/squid3

  • Avatar Vsla Dds says:

    ehowstuff@ubuntu14:~$ sudo apt-get install squid3 -y
    Why put “-y” at the end of the commands to install squid3

  • Avatar Sergio Soares says:

    Is there any way to add another user with authentication? If i try to add a new one it replaces the first one i create. Thanks

  • Avatar Mars says:

    Thanks for your sharing!

Leave a Reply

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