In this tutorial we will show you how to install and configuration of Squid on your CentOS server. For those of you who didn’t know, Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. Squid proxy is used by various organisation and internet providers to reduce bandwidth and to increase response time.
This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Squid in CentOS linux server.
Install and Configure Squid 3 on CentOS
Step 1. To install, first you must update yum repository and packages by typing the below command:
1 | #yum -y update |
Step 2. Installing Squid 3.
Install squid package and dependencies using the below command :
1 | #yum -y install squid |
Step 3. Configuration Squid.
Edit squid configuration file ‘/etc/squid/squid.conf’
1 | #nano /etc/squid/squid.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # Recommended minimum configuration: auth_parambasicprogram/usr/lib/squid/ncsa_auth/etc/squid/squid_passwd aclncsa_usersproxy_authREQUIRED http_accessallowncsa_users aclmanagerprotocache_object acllocalhostsrc127.0.0.1/32 aclto_localhostdst127.0.0.0/80.0.0.0/32 aclSSL_portsport443 aclSafe_portsport80 # http aclSafe_portsport21 # ftp aclSafe_portsport443 # https aclSafe_portsport1025-65535 # unregistered ports aclSafe_portsport280 # http-mgmt aclSafe_portsport488 # gss-http aclSafe_portsport591 # filemaker aclSafe_portsport777 # multiling http aclCONNECTmethodCONNECT http_accessallowmanagerlocalhost http_accessdenymanager http_accessdeny!Safe_ports http_accessdenyCONNECT!SSL_ports http_accessdenyall http_port3128 hierarchy_stoplistcgi-bin? coredump_dir/var/spool/squid cachedenyall refresh_pattern^ftp: 1440 20% 10080 refresh_pattern^gopher: 1440 0% 1440 refresh_pattern-i(/cgi-bin/|\?)0 0% 0 refresh_pattern. 0 20% 4320 icp_port3130 forwarded_foroff request_header_accessAllowallowall request_header_accessAuthorizationallowall request_header_accessProxy-Authorizationallowall request_header_accessProxy-Authenticateallowall request_header_accessCache-Controlallowall request_header_accessContent-Encodingallowall request_header_accessContent-Lengthallowall request_header_accessContent-Typeallowall request_header_accessDateallowall request_header_accessExpiresallowall request_header_accessHostallowall request_header_accessIf-Modified-Sinceallowall request_header_accessLast-Modifiedallowall request_header_accessLocationallowall request_header_accessPragmaallowall request_header_accessAcceptallowall request_header_accessAccept-Charsetallowall request_header_accessAccept-Encodingallowall request_header_accessAccept-Languageallowall request_header_accessContent-Languageallowall request_header_accessMime-Versionallowall request_header_accessRetry-Afterallowall request_header_accessTitleallowall request_header_accessConnectionallowall request_header_accessProxy-Connectionallowall request_header_accessUser-Agentallowall request_header_accessCookieallowall request_header_accessAlldenyall visible_hostnameidroot.us |
Step 4. Create our authentication file which Squid can use to verify for user authentications:
1 | #htpasswd -b /etc/squid/squid_passwd username password |
Example:
1 | #htpasswd -b -c /etc/squid/squid_passwd ranty ratna |
Congratulation’s! You have successfully installed squid. Thanks for using this tutorial for installing squid proxy on CentOS system. For additional help or useful information, we recommend you to check the official squid web site.