Installing `squid` as a sibling to an already existing Parent `squid`.
linux squid proxy
Squid is a caching and forwarding web proxy. It has a wide variety of uses, from speeding up a web server by caching repeated requests; to caching web, DNS and other computer network lookups for a group of people sharing network resources; to aiding security by filtering traffic.
- We are trying to create a sibling
squidwhich connects to a Parent
- Parent Squid only allows with
Assumption : We already have a
parent squid which uses authentication.
The reason why we do this is to make a single squid authenticate on behalf of all the nodes in the network.
In the current scenario, all the node which are in
172.22.x.x series which need to access the internet proxy, would have to add
username/password to their proxy setting, which is not secure and very difficult to maintain.
So what we do is to create a sibling
squid which does the authentication for us.
[`172.22.x.x`] | | +---> [sibling `squid`] <====(authenticate)====> [parent `squid`] | + ---------> (( `internet` ))
Command below install
[root@server-cloudera-manager yum.repos.d]# yum install squid Loaded plugins: product-id, rhnplugin, security, subscription-manager There was an error communicating with RHN. RHN Satellite or RHN Classic support will be disabled. Error communicating with server. The message was: Temporary failure in name resolution Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package squid.x86_64 7:3.1.23-9.el6 will be installed --> Processing Dependency: libltdl.so.7()(64bit) for package: 7:squid-3.1.2 --> Running transaction check ---> Package libtool-ltdl.x86_64 0:2.2.6-15.5.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository =========================================================================== Installing: squid x86_64 7:3.1.23-9.el6 rhel-6-serv Installing for dependencies: libtool-ltdl x86_64 2.2.6-15.5.el6 rhel-6-serv Transaction Summary =========================================================================== Install 2 Package(s) Total download size: 1.9 M Installed size: 6.4 M Is this ok [y/N]: y Downloading Packages: (1/2): libtool-ltdl-2.2.6-15.5.el6.x86_64.rpm (2/2): squid-3.1.23-9.el6.x86_64.rpm --------------------------------------------------------------------------- Total 233 kB/s Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libtool-ltdl-2.2.6-15.5.el6.x86_64 Installing : 7:squid-3.1.23-9.el6.x86_64 rhel-6-server-rpms/productid rhel-server-dts-6-rpms/productid Verifying : 7:squid-3.1.23-9.el6.x86_64 Verifying : libtool-ltdl-2.2.6-15.5.el6.x86_64 Installed: squid.x86_64 7:3.1.23-9.el6 Dependency Installed: libtool-ltdl.x86_64 0:2.2.6-15.5.el6 Complete!
Installation in complete. Now setting
[root@server-cloudera-manager yum.repos.d]# chkconfig squid on
Configuration of Squid.
We are configuring UK
squid as a
subling to the parent squid running in
Atlanta. This is how its going to work.
- Step 1. Configure
- Step 2. Configure all the
datanodesto connect to our proxy.
Working. And more on this here :
172.22.x.xwill connect to sibling
squidwill by-pass the requests to parent
18717using login authentication.
Configuration currently on
squid. Assuming we are allowing
Important lines to look for.
# Allowing `172.22.0.0/16` network. acl localnet src 172.22.0.0/16 # RFC1918 possible internal network
Setting port - sibling
squid will be listening on this port.
# Squid normally listens to port 3128 http_port 18716
cache_peer to connect to
parent_ip_addr will be the parent IP.
# setting `cache_peer` cache_peer parent_ip_addr parent 18717 0 proxy-only login=username:password default
Making sure all the request go through the
# we are making sure that all the traffic goes through the parent. never_direct allow all
Here is the complete configuration.
# # Recommended minimum configuration: # acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 # Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed # Allowing `172.22.0.0/16` network. acl localnet src 172.22.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow manager localhost http_access deny manager # Deny requests to certain unsafe ports http_access deny !Safe_ports # Deny CONNECT to other than secure SSL ports http_access deny CONNECT !SSL_ports # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user # http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # Example rule allowing access from your local networks. # Adapt localnet in the ACL section to list your (internal) IP networks # from where browsing should be allowed http_access allow localnet http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 18716 # Uncomment and adjust the following to add a disk cache directory. # cache_dir ufs /var/spool/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/spool/squid # setting `cache_peer` cache_peer parent_ip_addr parent 18717 0 proxy-only login=username:password default # we are making sure that all the traffic goes through the parent. never_direct allow all # Add any of your own refresh_pattern entries above these. 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
[root@server ~]# service squid restart
Configuration of clients to connect.
Add the below lines to the
env of the node which needs internet connection.
export http_proxy=http://sibling_squid_ip_addr:18716 export https_proxy=$http_proxy export ftp_proxy=$http_proxy
yum.conf on all HOSTS.
Add the below line in the end of