Posted by: jasonk2600 | November 6, 2009

Quickie HowTo – Squid Proxy Server on FreeBSD


Configure and install Squid from the FreeBSD ports collection.

# cd /usr/ports/www/squid31
# make config
# make install clean
# rehash


The following settings will configure Squid to provide proxy services to any hosts on any internal network.  It will proxy access to HTTP, HTTPS, FTP, Gopher, WAIS, and unregistered ports.  Finally, it will maintain a cache of 512MBs.  Add the following to /usr/local/etc/squid/squid.conf:

acl manager proto cache_object
acl localhost src
acl to_localhost dst
acl localnet src     # RFC1918 possible internal network
acl localnet src  # RFC1918 possible internal network
acl localnet src # RFC1918 possible internal network
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
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
coredump_dir /usr/local/squid/cache
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
cache_dir ufs /usr/local/squid/cache 512 16 256

After saving the new configuration, initialize the cache directory by executing the following command:

# squid -z

Finally, enable Squid to automatically start at system boot.

# echo "squid_enable=YES" >> /etc/rc.conf


Ensure that the freshly installed and configured Squid proxy server is functioning correctly.  Start Squid by executing the following command:

# /usr/local/etc/rc.d/squid start

Configure a web browser on another computer on the local network to use the Squid proxy server. Note that the Squid proxy server operates on port 3128. Once the browser is configured try browsing various random websites.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: