squid的代理功能配置
调整Cache的选项<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
l request_header_max_size 数字(KB)
最大http请求头
l request_body_max_size 数字(KB)
最大http请求数据内容
l reply_body_max_size 数字(KB)
最大返回数据,可限制用户下载的数据大小
l reference_age 数字
LRU算法中指定LRU时间
l quick_abort_min 数字(KB)
断点续传最小值
l quick_abort_max 数字(KB)
断点续传最大值
l quick_abort_pct 数字(percent)
超过值认为续传成功
l negative_ttl 数字 minutes/hours/seconds
否定回答TTL
l positive_dns_ttl 数字 minutes/hours/seconds
DNS肯定回答TTL
l range_offset_limit 数字 KB/MB/Bytes
请求SQUID预取数据的大小
(3) 定义超时的选项
l connect_timeout:SQUID等待客户请求的服务器回应的时间长度
l peer_connect_timeout:一个对等的缓存服务器的TCP连接超时时间
l client_lifetime:客户端同代理服务器TCP连接的最大时间长度
l read_timeout:读入数据超时
l request_timeout:客户端请求最大时间
l shutdown_lifetime:关闭squid缓存时间
(4) 定义访问控制的选项
l acl:定义一个访问列表
格式:acl aclname acltype string
类型:(acltype)
• src:源地址
• dst:目标地址
• srcdomain:原(客户)名称
• dstdomain:目标名称
• time:时间(M星期一、T星期二、W星期三、H星期四、F星期五、A星期六、S星期天)
• url_regex [-i]:URL中的正则表达式匹配
• urlpath_regex[-i]:略去协议和主机名的正则表达式
• proxy_auth:通过外部程序进行用户验证
• maxconn:单IP最大连接数
• port:端口
• myip:本地IP
• srcdom_regex [-i]:匹配客户名
• dstdom_regex [-i]:匹配目标名
• myport:我的端口
• proto:协议,http,ftp..
• method:方法, GET POST
• browser:匹配User-Agent header
• arp:匹配指定的MAC地址
• proxy_auth username:指定合法用户,用REQUIRED表示所有合法用户
l http_access:代理访问控制
格式:http_access allow|deny [!] acl_name
l icp_access:icp访问控制
格式:icp_access allow|deny [!]acl_name
l cache_peer_access:其它缓存服务器访问控制
格式:cache_peer_access cache_host allow|deny [!]acl_name
(5) 管理员参数选项
l cache_mgr mail地址:管理员电子邮件
l cache_effective_user 用户名:运行身份
l cache_effective_group 组名:运行组身份
(6) CACHE注册服务选项
l announce_period 数字:发布缓存通告频率
l announce_host 主机名:通告的主机
l announce_file 文件名:通告的信息
l announce_port 端口号:通告的对方端口
(7) HTTPD加速选项
l httpd_accel_host 主机名/vitual:加速某服务器访问
l httpd_accel_port 端口号:加速服务器的对方端口
l httpd_accel_single_host on/off:多台服务器时设置off
l httpd_accel_with_proxy on/off:即作为加速器,又作为WEB缓存服务器,设置为on
l httpd_accel_uses_host_header on/off:为on,能支持不同的http协议
(8) 杂项
l logfile_rotate 0-9:日志轮换版本数
l append_domain 域名:默认域名
l tcp_recv_bufsize 数字(KB):TCP缓存区大小
l err_html_text 字符串:包含在错误消息中的文本
l deny_info:禁用时显示消息
格式:deny_info err_page_name acl
l visible_hostname 主机名
错误消息中显示的服务器名称
l error_directory 路径:指定错误消息文件目录
2. 启动squid服务
#service squid start
二. 配置案例
案例一: 普通的代理服务器
利用squid架设一台普通的代理服务器,代理LAN(192.168.7.0/24)接入internet,并对客户进行身份验证
1. 安装squid
#rpm -ivh squid-2.5.STABLE1-2.i386.rpm
2. 配置squid.conf文件
#vi /etc/squid/squid.conf
http_port 8000
cache_mem 128 MB
cache_dir ufs /var/spool/squid 4096 16 256
cache_effective_user squid
cache_effective_group squid
dns_nameservers 202.102.192.68
cache_access_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
visible_hostname ww.abc.com
cache_mgr admin@squid.com
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic credentialsttl 2 hours
auth_param basic realm linux.com’squid
acl lan src 192168.7.0/255.255.255.0
acl users proxy_auth REQUIRED
http_access allow lan users
3. 建立squid用户
#htpasswd –c /etc/squid/passwd px1
4. 启动服务
#service squid start
案例二:透明代理服务器
利用Squid架设透明代理服务器.使LAN(192.168.7.0)可以接入internet
1. 安装squid
#rpm -ivh squid-2.5.STABLE1-2.i386.rpm
2. 配置squid.conf文件
#vi /etc/squid/squid.conf
http_port 8000
cache_mem 128 MB
cache_dir ufs /var/spool/squid 4096 16 256
cache_effective_user squid
cache_effective_group squid
dns_nameservers 202.102.192.68
cache_access_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
visible_hostname ww.abc.com
cache_mgr admin@squid.com
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
acl lan src 192168.7.0/255.255.255.0
http_access allow lan
3. 启动服务
#service squid start
案例三:反向代理服务器
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
1. 安装squid
#rpm -ivh squid-2.5.STABLE1-2.i386.rpm
2. 配置squid.conf文件
#vi /etc/squid/squid.conf
http_port 8000
cache_mem 128 MB
cache_dir ufs /var/spool/squid 4096 16 256
cache_effective_user squid
cache_effective_group squid
dns_nameservers 202.102.192.68
cache_access_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
visible_hostname ww.abc.com
cache_mgr admin@squid.com
http_port 80 # squid监听的端口
httpd_accel_host 172.16.250.250 # 内部WEB服务器的IP地址
httpd_accel_port 80 # WEB服务器的IP地址
httpd_accel_single_host on # 转发为缓冲的请求到一台单独的机器
httpd_accel_with_proxy on #
httpd_accel_uses_host_header off
httpd_accel_host 172.16.250.250 # 内部WEB服务器的IP地址
httpd_accel_port 80 # WEB服务器的IP地址
httpd_accel_single_host on # 转发为缓冲的请求到一台单独的机器
httpd_accel_with_proxy on #
httpd_accel_uses_host_header off
acl lan src 192168.7.0/255.255.255.0
http_access allow lan
3. 启动服务
#service squid start
转载于:https://blog.51cto.com/hulun/477099