1、安装squid
--------------------------------------------------
freebsd# cd /usr/ports/www/squid3
freebsd# make install clean
2、编辑squid.conf
-------------------------------------------------
vi /usr/local/etc/squid.conf
http_port 80
cache_effective_user nobody
cache_effective_group nobody
cache_mem 512 MB
maximum_object_size_in_memory 10MB
memory_replacement_policy lru
cache_dir ufs /usr/local/squid/cache 8000 32 128
max_open_disk_fds 0
maximum_object_size 200MB
pid_filename /usr/local/squid/var/logs/squid.pid
cache_swap_low 90
cache_swap_high 95
cache_store_log none
http_access allow all
3、启动squid
---------------------------------------------
freebsd# chmod -R 777 /usr/local/squid
freebsd# chmod -R 777 /usr/local/etc/squid
freebsd# /usr/local/sbin/squid -z
freebsd# /usr/local/etc/rc.d/squid start
 
4、添加规则
-------------------------------------------
freebsd# vi /etc/rc.conf
squid_enable="YES"
freebsd# vi /etc/pf.conf
pass in quick proto tcp from any to $ext_if port 80

5、设置用户认证
---------------------------------------------
freebsd# htpasswd -c /usr/local/etc/squid/sqpasswd king     //生成sqpasswd认证文件,并创建king用户
freebsd# htpasswd /usr/local/etc/squid/sqpasswd kerry       //添加kerry用户
修改squid.conf,enable ncsa_auth用户认证功能
vi /usr/local/etc/squid.conf
auth_param basic program /usr/local/libexec/squid/ncsa_auth /usr/local/etc/squid/sqpasswd
acl jav proxy_auth kerry king
http_access allow jav