Menu

How to install the SQUID proxy server

The quickest way to run a proxy server is with Docker:

docker run --name squid -p 3128:3128 --rm -d \
  -e PROXYLOGIN=mylogin \
  -e PROXYPASSWORD=mypassword \
  anticaptcha/squid

If you wish to set your own configuration file, where you'd set up authentication, then mount it to /etc/squid/squid.conf

docker run --name squid -p 3128:3128 --rm -d \
 -v /path/to/squid.conf:/etc/squid/squid.conf \
anticaptcha/squid

Another way is to build from source:

yum -y install make gcc gcc-c++ libtool wget httpd-tools
wget http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.3.tar.gz
tar -zxf squid-3.2.3.tar.gz
cd squid-3.2.3
./configure
make
make install

An example of a configuration file:

#configure the port number
http_port 9191

cache_mem 5 MB
cache_dir ufs /usr/local/squid/var/cache 300 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
pid_filename /usr/local/squid/var/logs/squid.pid



auth_param basic program /usr/local/squid/libexec/basic_ncsa_auth /usr/local/squid/etc/squid_users

auth_param basic children 5
auth_param basic realm enter_your_pass
auth_param basic credentialsttl 2 hours

error_directory /usr/local/squid/share/errors/


acl SSL_ports port 443
acl Safe_ports port 80 8080 3128 # http
acl Safe_ports port 443# https
acl CONNECT method CONNECT
acl MYUSERS proxy_auth REQUIRED
acl to_ipv6 dst ipv6


http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow net


#allow only athorized users
http_access allow MYUSERS
http_reply_access allow all
icp_access deny all
miss_access allow all


#squid will run under nobody user
cache_effective_user nobody
cache_effective_group nobody
coredump_dir /usr/local/squid/var/cache


## making it anonymous
forwarded_for transparent
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_header_access Cache-Control deny all

SQUID keeps logins and passwords in a separate file. In our case, it's "/usr/local/squid/etc/squid_users". To manage this file, use "htpasswd" tool:

htpasswd -c /usr/local/squid/etc/squid_users mylogin

After you've done with configuration, change the permissions of SQUID's directories and run it as a daemon:

chown -R nobody:nobody /usr/local/squid/share /usr/local/squid/var
/usr/local/squid/sbin/squid -z /usr/local/squid/etc/squid.conf
/usr/local/squid/sbin/squid -f /usr/local/squid/etc/squid.conf

Check that the proxy is running and accepting connections:

netstat -lenp|grep squid

curl -x IP_HERE:3128 -U mylogin:mypassword http://antigate.com/iptest.php