当前位置: 首页 > 工具软件 > Squid > 使用案例 >

squid配置文件 squid.conf

杜英范
2023-12-01
################## 基本信息配置 ##################

#设置代理服务器名称

visible_hostname www.testsquid.com

#设置缓存服务器管理员邮箱

cache_mgr wangw@wisedu.com

#设置运行squid的用户和组

cache_effective_user nobody

cache_effective_group nobody

#################缓存相关参数设置################

#设置缓存内存大小,最大使用内存为1024M,

#当使用超过95%时开始对缓存进行替换,直到下降到90%后停止。

cache_mem 1024 MB

cache_swap_low 90

cache_swap_high 95

#设置磁盘中可缓存的最大文件大小

maximum_object_size 12000 KB

#设置内存中最大可缓存的最大文件大小

maximum_object_size_in_memory 1024 KB

#设置缓存文件夹的路径和参数,10000表示10G大小,目录下面分为16级,每级又有256个目录

cache_dir ufs /var/spool/squid 10000 16 256

#设置缓存日志文件路径

cache_access_log /var/log/squid/access.log

cache_log /var/log/squid/cache.log

cache_store_log /var/log/squid/store.log

###########反向代理相关设置#################################

#设置反向代理服务器监听的端口为80,accel表示开启squid的accel加速模式,

#vhost和vport表示支持虚拟主机和虚拟端口,如果再加上transparent表示支持透明代理

http_port 80 accel vhost vport

#cache_peer表示如果本机缓存中找不到客户端请求的数据,将与主机www.zcu.com以parent类型进行联系,no-query表示不使用ICP协议进行联系,而是使用HTTP协议进行联系,联系端口是80,orginserver表示此服务器是源服务器,name表示别名。

cache_peer www.testsquid.com parent 80 0 no-query originserver name=testsquidone

cache_peer www.testsquidtwo.com parent 80 0 no-query originserver name=testsquidtwo

cache_peer www.testsquidthree.com parent 80 0 no-query originserver name=testsquidthree

#设置别名所对应的域名,如果cache_peer中使用域名而不是IP的话,那么cache_peer_domain中一定要用相同的域名,否则无法访问。

cache_peer_domain testsquidone www.testsquid.com

cache_peer_domain testsquidtwo www.testsquidtwo.com

cache_peer_domain testsquidthree www.testsquidthree.com

#设置访问控制,允许所有客户端访问上面设置的三个网站

http_access allow all

 类似资料: