在Linux上安装Squid代理服务器软件的详细步骤
1、获取Squid源代码
wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.9.tar.gz
2、编译及安装
tar -zxvf squid-3.1.9.tar.gz cd squid-3.1.9 ./configure --prefix=/usr/local/squid --enable-arp-acl --enable-linux-netfilter --enable-pthreads --enable-err-language="Simplify_Chinese" --enable-default-err-language="Simplify_Chinese" --enable-auth="basic" --enable-baisc-auth-helpers="NCSA" --enable-underscore make make install
3、编译生成Squid认证程序ncsa_auth
cd helpers/basic_auth/NCSA/ make cp ncsa_auth /usr/sbin/ cd ../../../
4、使用htpasswd来生成用户名/密码对应的文件
htpasswd -c /usr/local/squid/password <用户名>
5、修改Squid配置文件
cd /usr/local/squid/ mv -f etc/squid.conf etc/squid.conf.bak vi etc/squid.conf # 插入如下内容 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 auth_param basic program /usr/sbin/ncsa_auth /usr/local/squid/password acl normal proxy_auth REQUIRED http_access allow normal # Deny requests to certain unsafe ports http_access deny !Safe_ports # Deny CONNECT to other than secure SSL ports http_access deny CONNECT !SSL_ports # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 # We recommend you to use at least the following line. hierarchy_stoplist cgi-bin ? # Uncomment and adjust the following to add a disk cache directory. #cache_dir null /tmp # Leave coredumps in the first cache dir coredump_dir /usr/local/squid/var/cache # Add any of your own refresh_pattern entries above these. 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
6、启动Squid
./sbin/squid
转载:http://www.oschina.net/code/snippet_4873_1535