Posted by: jasonk2600 | November 6, 2009

Quickie HowTo – Squid Proxy Server on FreeBSD

Installation

Configure and install Squid from the FreeBSD ports collection.

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

Configuration

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 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # 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
acl CONNECT method CONNECT
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

Testing

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.

 [EoF]
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Categories

%d bloggers like this: