{"id":70,"date":"2012-08-23T22:22:00","date_gmt":"2012-08-23T22:22:00","guid":{"rendered":"https:\/\/www.tech-and-dev.com\/blog\/2012\/08\/23\/turning-your-server-into-a-proxy-using-squid\/"},"modified":"2021-02-22T01:19:40","modified_gmt":"2021-02-22T01:19:40","slug":"turning-your-server-into-proxy-using-squid","status":"publish","type":"post","link":"https:\/\/www.tech-and-dev.com\/blog\/2012\/08\/turning-your-server-into-proxy-using-squid.html","title":{"rendered":"Turning your server into a proxy using Squid"},"content":{"rendered":"<div style=\"clear: both; text-align: center;\"><img decoding=\"async\" src=\"https:\/\/www.tech-and-dev.com\/blog\/wp-content\/uploads\/2021\/02\/squid-proxy-logo.png\" border=\"0\" \/><\/div>\n<div style=\"text-align: justify;\">Squid is a fully-featured HTTP\/1.0 proxy. Squid offers a rich access control, authorization and logging environment to develop web proxy and content serving applications.<\/div>\n<h2><span style=\"font-size: x-large;\">\u00a0<\/span><\/h2>\n<h2><span style=\"font-size: x-large;\">\u00a0<\/span><\/h2>\n<h2><span style=\"font-size: x-large;\">\u00a0<\/span><\/h2>\n<h2><span style=\"font-size: x-large;\">Installing Squid<\/span><\/h2>\n<p>To install squid on CentOS, use yum install command (you must be logged in as root (If you&#8217;re not familiar with yum and root access, you might want to check the following topic first: <a href=\"http:\/\/www.tech-and-dev.com\/2012\/07\/20-most-used-linux-commands-and-how-to-use-them.html\" target=\"_blank\" rel=\"noopener\">15 most used linux commands and how to use them<\/a>)):<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\"><span style=\"font-family: 'Courier New',Courier,monospace;\">yum install squid<\/span><\/div>\n<p>&nbsp;<\/p>\n<div style=\"text-align: justify;\">If you can&#8217;t install squid using yum, you can download it from http:\/\/www1.dk.squid-cache.org\/Versions\/ using wget command (<a href=\"http:\/\/www.tech-and-dev.com\/2012\/07\/working-with-wget-command-to-download.html\" target=\"_blank\" rel=\"noopener\">how to use wget<\/a>)<\/div>\n<div style=\"text-align: justify;\">Next you have to extract the compressed archive file and change the working directory to the squid directory:<\/div>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">tar -xvzf squid-*-src.tar.gz<br \/>\ncd squid -*<\/div>\n<p>Now enter the following commands in order to configure, compile and install squid<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">.\/configure<br \/>\nmake<br \/>\nmake install<\/div>\n<p>This by default, will install it in &#8220;\/usr\/local\/squid&#8221;.<br \/>\nType <b>.\/configure &#8211;help<\/b> to view all available options.<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: x-large;\">Configuring Squid<\/span><\/h2>\n<p>In order to configure squid, we open the squid configuration file located in \/etc\/squid<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">vi \/etc\/squid\/squid.conf<\/div>\n<p>By default, squid will listen on port 3128, to make it listen on port 3128, 8080 and port 2083, we add the following:<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">http_port 3128<br \/>\nhttp_port 2083<br \/>\nhttp_port 8080<\/div>\n<p>or if you want to define an IP to listen to instead of all IPs, replace YOUR_SERVER_IP by your server IP:<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">http_port YOUR_SERVER_IP:3128<br \/>\nhttp_port YOUR_SERVER_IP:2083<br \/>\nhttp_port YOUR_SERVER_IP:8080<\/div>\n<p>&nbsp;<\/p>\n<div style=\"text-align: justify;\">By default all the http access are denied. The ACL rules must be modified to allow access only to trusted users or all users. This is important if you don&#8217;t want everyone to use your proxy server and eventually consume resources.<\/div>\n<p>To allow everyone to access and use the proxy server, append the following line to the configuration file:<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">http_access allow all<\/div>\n<p>(make sure to remove the line <b>http_access deny all<\/b> for the above to work)<\/p>\n<p>To allow a range of IPs instead of allowing everyone, add the following command<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">acl my_ranged_ips src 1.2.3.1-1.2.3.254\/24<br \/>\nhttp_access allow my_ranged_ips<br \/>\nhttp_access deny all<\/div>\n<p>&nbsp;<\/p>\n<div style=\"text-align: justify;\">Make sure that <b>http_access deny all <\/b>is the last statement, this is because the ACLs are checked from top to bottom. Users with IPs in the range of my_ranged_ips will be allowed to use the server, anyone else falls through to the &#8220;deny all&#8221; and gets a failure message.<\/div>\n<p>Once the configurations are done, restart squid:<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">service squid restart<\/div>\n<p>To stop squid<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">service squid stop<\/div>\n<p>To start squid<\/p>\n<div style=\"background-color: black; color: white; font-family: 'Courier New',Courier,monospace; padding: 5px;\">service squid start<\/div>\n<p><b>Any comments, questions or suggestions? Post below!<\/b><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Squid is a fully-featured HTTP\/1.0 proxy. Squid offers a rich access control, authorization and logging environment to develop web proxy and content serving applications. \u00a0 \u00a0 \u00a0 Installing Squid To install squid on CentOS, use yum install command (you must be logged in as root (If you&#8217;re not familiar with yum and root access, you [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[88,31,89],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-proxy","category-server","category-squid"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":4,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":394,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions\/394"}],"wp:attachment":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}