Installing Squid Proxy on Ubuntu Server

First, let’s update the repositories:
apt-get update
Then install the proxy software and the associated password generator:
apt-get install squid apache2-utils
Once that’s done, let’s create an empty configuration file:
rm -rf /etc/squid/squid.conf touch /etc/squid/squid.conf chown proxy /etc/squid/squid.conf
Then create the password file:
touch /etc/squid/squid_passwd
Then grant permissions to the proxy:
chown proxy /etc/squid/squid_passwd
Start editing the configuration file:
nano /etc/squid/squid.conf
and add the following lines (for http_port, specify the port you want to connect to the proxy on):
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/squid_passwd auth_param basic realm proxy acl authenticated proxy_auth REQUIRED http_access allow authenticated http_port 1337 forwarded_for off request_header_access Allow allow all request_header_access Authorization allow all request_header_access WWW-Authenticate allow all request_header_access Proxy-Authorization allow all request_header_access Proxy-Authenticate allow all request_header_access Cache-Control allow all request_header_access Content-Encoding allow all request_header_access Content-Length allow all request_header_access Content-Type allow all request_header_access Date allow all request_header_access Expires allow all request_header_access Host allow all request_header_access If-Modified-Since allow all request_header_access Last-Modified allow all request_header_access Location allow all request_header_access Pragma allow all request_header_access Accept allow all request_header_access Accept-Charset allow all request_header_access Accept-Encoding allow all request_header_access Accept-Language allow all request_header_access Content-Language allow all request_header_access Mime-Version allow all request_header_access Retry-After allow all request_header_access Title allow all request_header_access Connection allow all request_header_access Proxy-Connection allow all request_header_access User-Agent allow all request_header_access Cookie allow all request_header_access All deny all
Once that’s done, you need to add a username and password:
htpasswd /etc/squid/squid_passwd username
You can add more users later using the same command. Then just restart the service and you’re done:
service squid restart
You can connect to the proxy on port 1337, or whichever port you changed it to, using the specified username and password.
Read other posts