{"id":5195,"date":"2014-07-03T00:07:00","date_gmt":"2014-07-02T16:07:00","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=5195"},"modified":"2023-09-18T16:13:10","modified_gmt":"2023-09-18T16:13:10","slug":"how-to-setup-squid-proxy-in-ubuntu","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-squid-proxy-in-ubuntu\/","title":{"rendered":"How to Setup Squid Proxy in Ubuntu Server 14.04"},"content":{"rendered":"<p>Selecting the right <a href=\"https:\/\/webhostinggeeks.com\/best\/proxy-servers\/\">proxy server software<\/a> for your dedicated, VPS, or cloud hosting machine can significantly enhance your web operations.<\/p>\n<p>One of the most reliable and efficient options is <a href=\"https:\/\/webhostinggeeks.com\/blog\/squid-proxy-server-features-functions-benefits\/\">Squid<\/a>, a proxy server that provides cache services to its clients. Squid redirects client requests from web browsers to the proxy server, delivers the client&#8217;s requests, and keeps a copy of them in the proxy hard disk cache.<\/p>\n<p>This process speeds up internet access, especially for frequently-used files, and reduces internet bandwidth usage.<\/p>\n<p>In this tutorial, we will guide you through the process of setting up Squid Proxy on an <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a> Server 14.04. We will cover everything from installation to configuration, ensuring that you can get your proxy server up and running efficiently. By the end of this guide, you will have a fully functional Squid Proxy server that can enhance your web operations and improve your overall server performance.<\/p>\n<h2>Step 1: Install Squid 3<\/h2>\n<pre>\r\nsudo apt-get install squid3 -y\r\n<\/pre>\n<h2>Step 2: Configure Common Settings<\/h2>\n<pre>\r\nsudo vi \/etc\/squid3\/squid.conf\r\n<\/pre>\n<p>Around line 919, define the allowed LAN segment:<\/p>\n<pre>\r\nacl lan_ehowstuff src 192.168.0.0\/24\r\n<\/pre>\n<p>Around line 1058, allow the defined LAN:<\/p>\n<pre>\r\nhttp_access allow lan_ehowstuff\r\n<\/pre>\n<p>Listen on port 3128:<\/p>\n<pre>\r\nhttp_port 3128\r\n<\/pre>\n<p>Save the configuration.<\/p>\n<h2>Step 3: Configure Squid Proxy Authentication using Digest Authentication Scheme<\/h2>\n<p>a. Install the program \u2018htdigest\u2019:<\/p>\n<pre>\r\nsudo apt-get install apache2-utils -y\r\n<\/pre>\n<p>b. Set up user:<\/p>\n<pre>\r\nsudo htdigest -c \/etc\/squid3\/passwords realm_name user_name\r\n<\/pre>\n<p>Example:<\/p>\n<pre>\r\nsudo htdigest -c \/etc\/squid3\/passwords proxy proxyuser1\r\n<\/pre>\n<p>c. At lines 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.<\/p>\n<pre>\r\nauth_param digest program \/usr\/lib\/squid3\/digest_file_auth -c \/etc\/squid3\/passwords\r\nauth_param digest realm proxy\r\nacl authenticated_ehowstuff proxy_auth REQUIRED\r\nhttp_access allow authenticated_ehowstuff\r\n<\/pre>\n<h2>Step 4: Restart the Squid to Take Effect the New Configuration<\/h2>\n<pre>\r\nsudo initctl restart squid3\r\n<\/pre>\n<p>or<\/p>\n<pre>\r\nsudo service squid3 restart\r\n<\/pre>\n<h2>Step 5: Verify Port 3128 are Listening<\/h2>\n<pre>\r\nsudo netstat -plunt | grep 3128\r\n<\/pre>\n<h2>Step 6: Configure at Client Browser<\/h2>\n<p>Every time you open the browser, the proxy authentication box will be prompted.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-5378 size-full img-fluid lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/07\/Ubuntu-squid2.png\" alt=\"How to Setup Squid Proxy in Ubuntu\" width=\"589\" height=\"165\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/07\/Ubuntu-squid2.png 589w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/07\/Ubuntu-squid2-300x84.png 300w\" data-sizes=\"(max-width: 589px) 100vw, 589px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 589px; --smush-placeholder-aspect-ratio: 589\/165;\" \/><\/p>\n<h2>Step 7: Monitor the Access Log from Proxy Server<\/h2>\n<p>You can see proxyuser1 as the authenticated user:<\/p>\n<pre>\r\nsudo tail -f \/var\/log\/squid3\/access.log\r\n<\/pre>\n<p>For example:<\/p>\n<pre>\r\ngeeks@ubuntu14:~$ sudo tail -f \/var\/log\/squid3\/access.log\r\nRECT\/173.194.126.55 text\/html\r\n1409354804.372   1073 192.168.0.1 TCP_MISS\/200 776 GET http:\/\/xml.alexa.com\/data? proxyuser1 HIER_DIRECT\/23.21.109.107 text\/xml\r\n1409354842.754    963 192.168.0.1 TCP_MISS\/200 2285 POST http:\/\/sd.symcd.com\/ proxyuser1 HIER_DIRECT\/23.51.43.27 application\/ocsp-response\r\n1409354843.234   1489 192.168.0.1 TCP_MISS\/200 915 POST http:\/\/ocsp.digicert.com\/ proxyuser1 HIER_DIRECT\/117.18.237.29 application\/ocsp-response\r\n1409354843.454   1549 192.168.0.1 TCP_MISS\/200 2285 POST http:\/\/sd.symcd.com\/ proxyuser1 HIER_DIRECT\/23.51.43.27 application\/ocsp-response\r\n1409354848.074   3249 192.168.0.1 TCP_MISS_ABORTED\/000 0 POST http:\/\/ocsp.thawte.com\/ proxyuser1 HIER_NONE\/- -\r\n1409354848.877   3248 192.168.0.1 TCP_MISS_ABORTED\/000 0 POST http:\/\/ocsp.thawte.com\/ proxyuser1 HIER_DIRECT\/199.7.71.72 -\r\n1409354853.997   1120 192.168.0.1 TCP_MISS\/200 794 GET http:\/\/hsrd.yahoo.com\/_ylt=A86.IsJVDAFUTGsAVsJUqcB_;_ylu=X3oDMTQ0aHJqM2NuBGNjb2RlA2hvbWVydW4yBGNwb3MDMARnAzAyMTMtMGExNGQ5Zjc1NWZkZGUyYTY5M2E0ZmViNzE0MDUwOTctMDAxNARpbnRsA215BHBrZ3QDNARwb3MDMgRzZWMDdGQtb2ZsLWIEc2xrA3RpdGxlBHRlc3QDNjg0BHdvZQM5MTc5OTMzMg--\/RV=1\/RE=1410564437\/RH=aHNyZC55YWhvby5jb20-\/RO=2\/RU=aHR0cHM6Ly9teS5zcG9ydHMueWFob28uY29tL2ZhbnRhc3kvc29jY2VyL3ByZW1pZXItbGVhZ3Vl\/RS=%5EADA7H0JFo.Ud2RQRqK4zKbm5QoTGVg- proxyuser1 HIER_DIRECT\/206.190.39.139 text\/html\r\n1409354854.482    280 192.168.0.1 TCP_MISS\/200 446 GET http:\/\/toolbarqueries.google.com\/tbr? proxyuser1 HIER_DIRECT\/58.27.61.123 text\/html\r\n1409354854.750    549 192.168.0.1 TCP_MISS\/200 4214 GET http:\/\/xml.alexa.com\/data? proxyuser1 HIER_DIRECT\/23.21.109.107 text\/xml\r\n<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt-get install squid3 -y<\/span> \u2013 This command installs Squid 3 on your server.<\/li>\n<li><span class=\"fw-bold\">sudo vi \/etc\/squid3\/squid.conf<\/span> \u2013 This command opens the Squid configuration file for editing.<\/li>\n<li><span class=\"fw-bold\">acl lan_ehowstuff src 192.168.0.0\/24<\/span> \u2013 This command defines the allowed LAN segment.<\/li>\n<li><span class=\"fw-bold\">http_access allow lan_ehowstuff<\/span> \u2013 This command allows the defined LAN.<\/li>\n<li><span class=\"fw-bold\">http_port 3128<\/span> \u2013 This command sets Squid to listen on port 3128.<\/li>\n<li><span class=\"fw-bold\">sudo apt-get install apache2-utils -y<\/span> \u2013 This command installs the &#8216;htdigest&#8217; program.<\/li>\n<li><span class=\"fw-bold\">sudo htdigest -c \/etc\/squid3\/passwords realm_name user_name<\/span> \u2013 This command sets up a user for the digest authentication scheme.<\/li>\n<li><span class=\"fw-bold\">auth_param digest program \/usr\/lib\/squid3\/digest_file_auth -c \/etc\/squid3\/passwords<\/span> \u2013 This command adds the digest authentication configuration.<\/li>\n<li><span class=\"fw-bold\">sudo initctl restart squid3<\/span> or <span class=\"fw-bold\">sudo service squid3 restart<\/span> \u2013 These commands restart Squid to apply the new configuration.<\/li>\n<li><span class=\"fw-bold\">sudo netstat -plunt | grep 3128<\/span> \u2013 This command verifies that Squid is listening on port 3128.<\/li>\n<li><span class=\"fw-bold\">sudo tail -f \/var\/log\/squid3\/access.log<\/span> \u2013 This command monitors the access log from the proxy server.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Setting up a Squid Proxy on an Ubuntu Server 14.04 is a straightforward process that can significantly enhance your web operations. By following the steps outlined in this tutorial, you can install and configure Squid, set up a user for the digest authentication scheme, and monitor the access log from the proxy server.<\/p>\n<p>Remember, Squid is a powerful tool that can speed up internet access, especially for frequently-used files, and reduce internet bandwidth usage. It&#8217;s a valuable addition to any server, whether it&#8217;s a dedicated server, a VPS, or a cloud hosting machine.<\/p>\n<p>I hope this tutorial has been helpful. If you have any questions or run into any issues, please leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Selecting the right proxy server software for your dedicated, VPS, or cloud hosting machine can significantly enhance your web operations. One of the most reliable and efficient options is Squid,&#8230;<\/p>\n","protected":false},"author":6,"featured_media":5198,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1057,1073],"tags":[1793,1856,1859],"class_list":["post-5195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-squid-server","category-ubuntu","tag-squid","tag-ubuntu","tag-ubuntu-14-04-lts"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=5195"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5195\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/5198"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=5195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=5195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=5195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}