您的位置:首页 > 运维架构 > 反向代理

缓存服务器squid2.7配置

2012-11-19 11:42 148 查看
#指定Squid监听客户机请求的端口号

http_port 192.168.0.241:3128

#允许局域网所有IP访问所有外网IP地址

acl all src 0.0.0.0/0.0.0.0

#设置代理协议为http

acl manager proto http

#允午本机IP

acl localhost src 127.0.0.1/255.255.255.255

#允午目的地址为本机IP

acl to_localhost dst 127.0.0.1

#端口所对应协议名称

acl Safe_ports port 80 # http

acl Safe_ports port 21 # ftp

acl Safe_ports port 210 # wais

acl Safe_ports port 443 # https

acl Safe_ports port 70 # gopher

acl Safe_ports port 488 # gss-http

acl Safe_ports port 280 # http-mgmt

acl Safe_ports port 591 # filemaker

acl Safe_ports port 777 # multiling http

acl Safe_ports port 1025-65535 # unregistered ports

#请求以双向握手方式处理

acl CONNECT method CONNECT

#允许局域网内所客户机使用本代理

http_access allow all

#允许任何客户端使用本代理

http_reply_access allow all

#限制每个IP最大允许128个连接,防止攻击

acl OverConnLimit maxconn 128

http_access deny OverConnLimit

#允许直接更新请求

miss_access allow all

#禁止服务器检查DNS

ident_lookup_access deny all

#以https://开头的认证连接不被缓存

hierarchy_stoplist -i ^https:\\ ?

acl denyssl urlpath_regex -i ^https:\\

no_cache deny QUERY

#设置内存一级缓冲区大小(为实际内存的1/3)

cache_mem 4096 MB

#设置内存预读缓冲区大小

memory_pools on

memory_pools_limit 1024 MB

#允许内存高速缓冲区内,存在的最小缓存文件

minimum_object_size 1 KB

#允许内存高速缓冲区内,存在的最大缓存文件

maximum_object_size_in_memory 3 MB

#动态使用最少的,移出内存一级缓冲区

memory_replacement_policy lru

#动态使用最少的,移出硬盘二级缓冲区

cache_replacement_policy lru

#设置缓存区保存数据位置以及缓冲区大小,1.6T一级目录32个,二级目录512个

cache_dir ufs /var/spool/squid 1600000 32 512

#允许最大打开文件数量0为无限制

max_open_disk_fds 0

#允许最大存在缓存区的文件

maximum_object_size 1024 MB

#允许缓冲区使用硬盘空余容量最大值90%

cache_swap_high 90

#允许缓冲区使用硬盘空余容量最小值80%

cache_swap_low 80

#设置IP解析缓存大小

ipcache_size 4096

#设置IP解析缓存最高占用值90%

ipcache_high 90

#设置IP解析缓存最低占用值80%

ipcache_low 80

#定义日志存放记录位置

cache_log /var/log/squid/cache.log

cache_store_log /var/log/squid/store.log

cache_access_log /var/log/squid/access.log

#禁止记录用户地址以降低负载

log_fqdn off

#禁止store日志

cache_store_log none

#获取用户IP

forwarded_for on

#禁止ICP高速缓存的查询日志

log_icp_queries off

#指定文件删除进程的完整路径。

unlinkd_program /usr/lib/squid/unlinkd

#设置Squid仿照Web服务器的格式创建访问记录

emulate_httpd_log on

#只允许http的请求

acl buggy_server url_regex ^http://.... http://
broken_posts allow buggy_server

#允许apache的编码

acl apache rep_header Server ^Apache

broken_vary_encoding allow apache

#禁止非http的标头请求,防止攻击

request_entities off

#允许所有的http报头

header_access header allow all

#不严格分析http报头

relaxed_header_parser on

#指定当缓冲出现问题时向缓冲管理者发送告警信息的地址信息

cache_mgr QQ:792866681

#邻居服务器缓冲内发送和接收ICP请求的端口号0是禁用

icp_port 0

#设置允许更新缓存的主机,因是本机所以127.0.0.1

cache_peer 127.0.0.1 parent 80 0 no-query default multicast-responder no-netdb-exchange

cache_peer_domain 127.0.0.1

hostname_aliases 127.0.0.1

#定义错误路径

error_directory /usr/share/squid/errors/Simplify_Chinese

#告诉Squid在错误页面中显示的服务器名称

visible_hostname No1.proxy

#告诉Squid如何处理用户,对每个请求的IP地址作为单独地址处理

client_netmask 255.255.255.255

#缓存丢失或不存在是允许所有请求直接转发到被请求的服务器

always_direct allow all

#设置Http请求包头大小

request_header_max_size 128 KB

#设置Http请求的数据大小

request_body_max_size 0 KB

#开反DNS查询,当域名地址不相同时候,禁止访问

ignore_unknown_nameservers off

#定义dump的目录

coredump_dir /var/log/squid

#最大打开的文件描述

max_filedesc 2048

#使服务器在客户机不再返回数据时立即关闭客户端的连接,以免占用资源

half_closed_clients off

#打开选项“buffered_logs”可以稍稍提高加速对日志文件的写入

buffered_logs on

#当用户中断请求时是否继续缓存

quick_abort_pct 85

#客户端不持续连接

client_persistent_connections off

#服务端持续连接

server_persistent_connections on

#设置消极存储对象的生存时间

negative_ttl 5 minutes

#设置缓存成功的DNS查询结果的生存时间为6小时

positive_dns_ttl 6 hours

#设置缓存失败的DNS查询结果的生存时间为5分钟

negative_dns_ttl 5 minutes

#设置等待连接完成的超时值为2分钟。

connect_timeout 120 seconds

#15分钟内未从被请求的服务器读入任何数据将终止该客户请求为

read_timeout 15 minutes

#设置在建立与客户的连接后将花多长时间等待客户发出HTTP请求为30秒。

request_timeout 30 seconds

#最大客户连接时间 360 分钟

client_lifetime 360 minute

#一旦从客户端返回no more data to read的信息就立即关闭该连接

half_closed_clients off

#在与其他服务器和代理建立连接后该连接闲置120秒后被关闭

pconn_timeout 120 seconds

#用户都收到超时信息为30秒

shutdown_lifetime 30 seconds

#缓存更新规则

refresh_pattern -i \.htm$ 7200 70% 10080 reload-into-ims

refresh_pattern -i \.html$ 7200 70% 10080 reload-into-ims

refresh_pattern -i \.css$ 7200 70% 10080 reload-into-ims

refresh_pattern -i \.js$ 7200 70% 10080 reload-into-ims

refresh_pattern -i \.xls$ 7200 70% 10080 ignore-reload

refresh_pattern -i \.css$ 7200 70% 10080 ignore-reload

refresh_pattern -i \.jpg$ 7200 80% 10080 ignore-reload

refresh_pattern -i \.jpeg$ 7200 80% 10080 ignore-reload

refresh_pattern -i \.gif$ 7200 80% 10080 ignore-reload

refresh_pattern -i \.png$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.bmp$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.ico$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.pnp$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.doc$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.txt$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.ppt$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.pdf$ 10080 80% 14400 ignore-reload

refresh_pattern -i \.mp3$ 10080 90% 14400 ignore-reload

refresh_pattern -i \.rar$ 10080 90% 14400 ignore-reload

refresh_pattern -i \.zip$ 10080 90% 14400 ignore-reload

refresh_pattern -i \.f4v$ 10080 90% 14400 ignore-reload

refresh_pattern -i \.swf$ 10080 90% 14400 ignore-reload

refresh_pattern . 0 60% 7200

refresh_pattern ^ftp: 1440 30% 4320

refresh_pattern ^gopher: 1440 0% 4320
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: