squid笔记下载_Squid学习笔记 - 很想当天的一切能回味 - OSCHINA - 中文开源技术交流社区...

1、部署

编译安装(以下编译安装参数适用Squid-3.0-stable20)

./configure --prefix=/usr/local/squid --enable-async-io=100 --with-pthreads --enable-storeio="ufs,aufs,diskd" --enable-removal-policies="heap,lru" --enable-icmp --enable-delay-pools  --enable-useragent-log --enable-regerer-log --enable-kill-parent-hack --enable-cachemgr-hostname=localhost  --enable-arp-acl --enable-default-err-language=English  --enable-err-languages="Simplify_Chinese English" --disable-poll --disable-wccp --disable-wccpv2 --disable-ident-lookups  --disable-internal-dns --enable-basic-auth-helpers="NCSA" --enable-stacktrace --with-large-files  --disable-mempools --with-filedescriptors=65536 --enable-ssl --enable-x-accelerator-vary --disable-snmp  --with-aio --enable-linux-netfilter --enable-linux-tproxy

make && make install

Squid编译安装参数说明

–prefix=/usr/local/squid :指定软件的安装路径

–enable-gnuregex :支持GNU正则表达式。

–disable-carp: Cache数组路由协议(CARP)用来转发丢失的cache到父cache的数组或cluste

–enable-async-io=240等同于同时打开./configure如下三个选项

--with-aufs-threads=N_THREADS

--with-pthreads

--enable-storeio=ufs,aufs

这个主要是设置async模式来运行squid,我的理解是设置用线程来运行squid,如果服务器配置很不错,有1G以上内存,cpu使用SMP的方式的话可以考虑设成160或者更高。如果服务器比较糟糕就根据实际情况设了。另外此项还另cache文件支持aufs

--disable-wccp用于阻止或分发HTTP请求到一个或多个caches

–enable-icmp :加入icmp支持

–enable-kill-parent-hack :关掉suqid的时候,要不要连同父进程一起关掉

--enable-cachemgr-hostname=localhost:指定cachemgr-hostname值为localhost

-- enable-snmp :此选项可以让MRTG使用SNMP协议对服务器的流量状态进行监测,因此必须选择此项,使Squid支持SNMP接口。

–disable-ident-lookups :防止系统使用RFC931规定的身份识别方法。

--enable-delay-pools 开启squid延时池功能

–enable-cahce-digests :加快请求时,检索缓存内容的速度。

–enable-err-language=”Simplify_Chinese” 和

–enable-default-err-languages=”Simplify_Chinese” :指定出错是显示的错误页面为简体中文

--with-maxfd=65535指定最大文件描述

–enable-poll :指定使用Poll()函数,提升性能就是啦。

--disable-ident-lookups允许服务器利用客户端的特殊TCP连接来发现用户名

–enable-linux-netfilter :可以支持透明代理

--enable-large-cache-files开启大文件支持,支持2GB以上的文件

--disable-internal-dns使用自己的内部DNS查询

–enable-underscore :允许解析的URL中出现下划线,因为默认squid会认为带下划线的URL地址是非法的,并拒绝访问该地址

–enable-arp-acl :可以在规则设置中直接通过客户端的MAC地址进行管理,防止客户使用IP欺骗。

2、配置

创建squid用户

useradd squid -M -s /sbin/nologin

修改SQUID用户及用户组,并开启cache_log和cache_store-log(access_log默认开启)

打开cache_dir

[root@asling-206 etc]# sed '/^#/d;/^$/d' squid.confacl 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 deny all

icp_access allow localnet

icp_access deny all

htcp_access allow localnet

htcp_access deny all

http_port 3128

hierarchy_stoplist cgi-bin ?

cache_dir ufs /usr/local/squid/var/cache 100 16 256

access_log /usr/local/squid/var/logs/access.log squid

cache_log /usr/local/squid/var/logs/cache.log

cache_store_log /usr/local/squid/var/logs/store.log

refresh_pattern ^ftp:  1440 20% 10080

refresh_pattern ^gopher: 1440 0% 1440

refresh_pattern (cgi-bin|\?) 0 0% 0

refresh_pattern .  0 20% 4320

cache_effective_user squid

cache_effective_group squid

icp_port 3130

coredump_dir /usr/local/squid/var/cache

[root@asling-206 etc]# sed '/^#/d;/^$/d' 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 deny all

icp_access allow localnet

icp_access deny all

htcp_access allow localnet

htcp_access deny all

http_port 3128

hierarchy_stoplist cgi-bin ?

cache_dir ufs /usr/local/squid/var/cache 100 16 256

access_log /usr/local/squid/var/logs/access.log squid

cache_log /usr/local/squid/var/logs/cache.log

cache_store_log /usr/local/squid/var/logs/store.log

refresh_pattern ^ftp:  1440 20% 10080

refresh_pattern ^gopher: 1440 0% 1440

refresh_pattern (cgi-bin|\?) 0 0% 0

refresh_pattern .  0 20% 4320

cache_effective_user squid

cache_effective_group squid

icp_port 3130

coredump_dir /usr/local/squid/var/cache

配置visible_hostname asling-206

squid3种日志:cache.log access.log cache_store_log

cache.log包含多种信息,例如squid的配置信息、性能警告以及严重错误,程序运行主要的错误和异常条件最可能报告在cache.log里面

在维护多个squid主机时,建议使用syslog来管理记录,配置主机的syslog进程转发到日志主机,在/etc/syslogd.conf里使用如下接口:

local4.notice     @192.168.0.88

store.log主要记录squid关于存储或者删除cache目标的决定,它既包含内存cache又包含磁盘cache,该日志对于运维来说作用不大,主要是可以通过它来分析客户端访问的数据是否被缓存,它包含了进入和离开缓存的每个目标的记录。可以通过定向到/dev/null来关闭。

ache_store_log /dev/null

3、squid访问控制:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值