Easy squid install

Replace xx.xx.xx.xx with the IP of the client you want to connect with.

#!/bin/bash
ip=xx.xx.xx.xx
apt-get install -y --force-yes sed squid squid-common
echo -e "header_access Proxy-Connection deny all\nheader_access X-Forwarded-For deny all\nheader_access Connection deny all\nheader_access Via deny all\nheader_access Cache-Control deny all\nheader_access Keep-Alive deny all" >> /etc/squid/squid.conf
#enable https
sed -i 's/http_access deny CONNECT !SSL_ports/#http_access deny CONNECT !SSL_ports/g' /etc/squid/squid.conf
#allow your ip
sed -i 's/acl localhost src 127.0.0.1\/32/acl localhost src 127.0.0.1\/32\nacl yournetwork src '$ip'/g' /etc/squid/squid.conf
#allow your ip2
sed -i 's/http_access allow localhost/http_access allow localhost\nhttp_access allow yournetwork/g' /etc/squid/squid.conf
/etc/init.d/squid restart

Alternative: Using password instead of IP

apt-get install -y --force-yes sed squid squid-common apache2-utils
sed -i 's/http_access deny CONNECT !SSL_ports/#http_access deny CONNECT !SSL_ports/g' /etc/squid/squid.conf
sed -i 's/http_access allow localhost/http_access allow localhost\nhttp_access allow all/g' /etc/squid/squid.conf

sed -i 's/#Recommended minimum configuration per scheme:/#Recommended minimum configuration per scheme:\nauth_param basic children 5\nauth_param basic realm Linux Class\nauth_param basic program \/usr\/lib\/squid\/ncsa_auth \/etc\/squid\/squid_user\nauth_param basic credentialsttl 2 hours\nauth_param basic casesensitive off\n/g' /etc/squid/squid.conf
sed -i 's/#acl password proxy_auth REQUIRED/acl class proxy_auth REQUIRED/g' /etc/squid/squid.conf
sed -i 's/http_access allow localhost/http_access allow localhost\nhttp_access allow class/g' /etc/squid/squid.conf
touch /etc/squid/squid_user
htpasswd /etc/squid/squid_user YOURUSERNAME

Fill in password twice, then restart squid

/etc/init.d/squid restart

Leave a Reply

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