FreeBSD(squid缓存服务器配置篇)

squid缓存服务器在这个实验环境中有两台(192.168.10.30,192.168.10.31)做成squid集群,我们首先安装一台,然后复制一台,再做配置,这样省事,哈!
squid01服务器网络配置
# ee /etc/rc.conf
ifconfig_lnc0="inet 192.168.10.30 netmask 255.255.255.0"
defaultrouter="192.168.10.10"          
hostname="squid01.rd.bj"

# ee /etc/hosts
192.168.10.30    squid01.rd.bj # ee /etc/resolv.conf
nameserver 192.168.10.40

网络配置好后,我们开始安装squid,先把的藏身处找到:
# whereis squid30
squid30: /usr/ports/www/squid30
# cd /usr/ports/www/squid30
# make config     #配置安装选项


# make showconfig    #我的配置选项
===> The following configuration options are available for squid-3.0.1:
SQUID_LDAP_AUTH=off "Install LDAP authentication helpers"
SQUID_SASL_AUTH=off "Install SASL authentication helpers"
SQUID_DELAY_POOLS=off "Enable delay pools"
SQUID_SNMP=on "Enable SNMP support"
SQUID_CARP=on "Enable CARP support"
SQUID_SSL=off "Enable SSL support for reverse proxies"
SQUID_PINGER=off "Install the icmp helper"
SQUID_DNS_HELPER=off "Use the old 'dnsserver' helper"
SQUID_HTCP=on "Enable HTCP support"
SQUID_VIA_DB=off "Enable forward/via database"
SQUID_CACHE_DIGESTS=on "Enable cache digests"
SQUID_WCCP=on "Enable Web Cache Coordination Prot. v1"
SQUID_WCCPV2=on "Enable Web Cache Coordination Prot. v2"
SQUID_STRICT_HTTP=on "Be strictly HTTP compliant"
SQUID_IDENT=on "Enable ident (RFC 931) lookups"
SQUID_REFERER_LOG=on "Enable Referer-header logging"
SQUID_USERAGENT_LOG=on "Enable User-Agent-header logging"
SQUID_ARP_ACL=off "Enable ACLs based on ethernet address"
SQUID_IPFW=off "Enable transparent proxying with IPFW"
SQUID_PF=off "Enable transparent proxying with PF"
SQUID_IPFILTER=off "Enable transp. proxying with IPFilter"
SQUID_ICAP=off "Enable ICAP client functionality"
SQUID_ESI=off "Enable ESI support (experimental)"
SQUID_AUFS=off "Enable the aufs storage scheme"
SQUID_COSS=off "Enable the COSS storage scheme"
SQUID_KQUEUE=on "Use kqueue(2) (experimental)"
SQUID_LARGEFILE=on "Support log and cache files >2GB"
SQUID_STACKTRACES=off "Create backtraces on fatal errors"
SQUID_DEBUG=off "Enable debugging options"
===> Use 'make config' to modify these settings
# make install clean

Squid 安装好了,现在开始配置她了。安装完后,在/usr/local/etc/squid下有squid的配置文件squid.conf和 squid.conf.default,这两个都是一样的,我们先删除掉squid.conf,在建个新的squid.conf,然后把我们的配置信息写 在里面,这样的话更加清晰一点,省得在原来的配置文件中改,里面内容那么多,改到后来,自己都不知道改了那些东西,糊涂了,如果对配置有什么不清楚的还是 可以参考squid.conf.default文件的。
# cd /usr/local/etc/squid
# rm -rf squid.conf
# touch squid.conf
# ee squid.conf
加入:
http_port 192.168.10.30:3128 vhost vport defaultsite=www.rd.bj

cache_mem 64 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 20 MB
minimum_object_size 0 KB
maximum_object_size_in_memory 5 MB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024

#acl all src 0.0.0.0/0.0.0.0 #好像squid30已经内置了
acl gsrc src 192.168.10.20 192.168.10.30 192.168.10.31 192.168.10.40
http_access allow gsrc

acl Manager proto cache_object
acl Localhost src 127.0.0.1
http_access allow Manager Localhost

acl Safe_ports port 3128 80 3130 3131
http_access deny !Safe_ports
http_access allow all

visible_hostname squid01.rd.bj
cache_mgr admin@rd.bj

cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65536 bytes

cache_peer 192.168.10.31 sibling 3128 3131
cache_peer_access 192.168.10.31 allow all
cache_peer 192.168.10.40 parent 80 0 no-query originserver no-digest

access_log /usr/local/squid/logs/access.log
cache_dir diskd /usr/local/squid/cache 256 16 256 Q1=60 Q2=50

error_directory /usr/local/etc/squid/errors/Simplify_Chinese

icp_port 3130
htcp_port 0
icp_query_timeout 2000
icp_access allow all
digest_generation on
log_icp_queries on
icp_hit_stale on
保存退出后,我们验证一下配置文件是否正确:
# rehash
# squid parse
如果没有什么信息出现的话,恭喜你,配置无误!
OK,现在我们先根据配置文件创建缓存目录。
# squid -z
2007/12/27 12:43:55| Creating Swap Directories
2007/12/27 12:43:55| /usr/local/squid/cache exists
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/00
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/01
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/02
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/03
2007/12/27 12:43:56| Making directories in /usr/local/squid/cache/04
2007/12/27 12:43:56| Making directories in /usr/local/squid/cache/05
2007/12/27 12:43:57| Making directories in /usr/local/squid/cache/06
2007/12/27 12:43:58| Making directories in /usr/local/squid/cache/07
2007/12/27 12:43:58| Making directories in /usr/local/squid/cache/08
2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/09
2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0A
2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0B
2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0C
2007/12/27 12:44:00| Making directories in /usr/local/squid/cache/0D
2007/12/27 12:44:00| Making directories in /usr/local/squid/cache/0E
2007/12/27 12:44:01| Making directories in /usr/local/squid/cache/0F

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywdwg.html