共享网络
加快访问速度,节约通信带宽
防止内部主机受到攻击
限制用户访问,完善网络管理
代理服务器原理
代理服务器接受到请求后,首先与访问控制列表中的访问规则相对照,如果满足规则,则在缓存中查找是否存在需要的信息。
客户端B向代理服务器提出相同的请求。代理服务器也首先与访问控制列表中的访问规则相对照。如果满足规则,则将缓存中的信息传送给客户端B
squid简介
访问控制清单和访问权限清单通过阻止特定的网络连接来减少潜在的Internet非法连接,可以使用这些清单来确保内部网的主机无法访问有威胁的或不适宜的站点。
以下是一些squid的基本配置参数解释
http_port 3128 //设置监听的IP与端口号
cache_mem 64 MB //设置内存缓冲的大小
cache_dir ufs /var/spool/squid 2000 16 256 //设置硬盘缓冲大小
cache_effective_user squid //设置缓存的有效用户
cache_effective_group squid //设置缓存的有效用户组
dns_nameservers 192.168.0.254 //设置DNS服务器地址,一般可以不设置,默认使用服务器自己设置的dns
cache_access_log /var/log/squid/access.log //设置访问日志文件
cache_log /var/log/squid/cache.log //设置缓存日志文件
visible_hostname 192.168.0.20 //设置squid主机名称
以上全局参数根据你自己的需要修改
其实linux下的服务器配置文件最好就是squid,它对每个参数都有解释,而且很多有很多实例
Acl的访问控制列表
语法:acl 列表名称 列表类型 [-i] 列表值
列表名称:用于区分Squid的各个访问控制列表,任何两个访问控制列表不能用相同的列表名。虽然列表名称可以随便定义,但为了避免以后不知道这条列表是干什么用的,应尽量使用有意义的名称,如badurl、clientip和work time等。
列表类型:是可被Squid识别的类别。Squid支持的控制类别很多,可以通过IP地址、主机名、MAC地址和用户/密码认证等识别用户,也可以通过域名、域后缀、文件类型、IP地址、端口和URL匹配等控制用户的访问,还可以使用时间区间对用户进行管理
-i选项:表示忽略列表值的大小写,否则Squid是区分大小写的。
列表值:针对不同的类型,列表值的内容是不同的。例如,对于类型为src或dst,列表值的内容是某台主机的IP地址或子网地址;对于类型为time,列表值的内容是时间;对于类型为srcdomain和dstdomain,列表值的内容是DNS域名。
列表类型和列表值,在配置文件中有很多例子
现在我们去看看
现在我们开始配置squid
默认有一条http_access deny all ,在2500多行,squid配置文件的acl生效顺序是从上到下,所以需要在这条前面写入允许语句
这个要注意,是squid服务器监听的端口
大家搜索ACCESS CONTROLS
我们一般把允许语句写到这个位置
加入两行,第一行是acl内容,定义源是192.168.8.0 网段
第二行是允许全部的语句
然后重新启动squid
OK了~
在windows下使用代理服务器,开IE,工具,inter选项,连接,局域网设置
现在你client就访问你服务器能访问的所有网站了
##############MICHAEL分割线##################
下面可以自己加一些策略,让squid按照我们的思路去工作
1、不允许192.168.8.24这个用户使用squid
记住deny要在允许所有之前,不然就会失效
修改配置文件,一定要记住重新启动
直接就访问拒绝了
这里有实例的
192.168.1.10-192.168.1.20/255.255.255.0的意思就是定义源为一个范围
src是源IP的意思
dst就是目标IP的意思
dstdomain是目标域名的意思
现在我们要192.168.8.24这个用户可以访问其他网站,但是不能访问163.com
其他用户的访问不受限制,大家有方法实现么?
这样就可以了
意思是同时匹配list2和list3就deny掉
注意:
acl list2 src 192.168.8.24 后面不能加上/255.255.255.0,否则会导致其他IP也不能访问163.com
acl list3 dstdomain .163.com,不能忘记加上".",正是它指出以此域名结尾的所有主机都不可访问,否则会导致不能访问163.com,而可以访问[url]www.163.com[/url]等哈~
[url]www.yahoo.com[/url]访问正常
[url]www.163.com[/url] 及news.163.com等163.com域名的网站禁止访问
[url]www.qq.com[/url]访问正常
看下其他客户端192.168.8.25
正常~~~
##############MICHAEL分割线##################
可以禁止用户通过网页下载某些特殊的扩展名字文件,如mp3,mp4
现在我们去添加策略
重新启动squid
现在就不能下载了
##############MICHAEL分割线##################
最后一个常用功能:基于时间的控制
192.168.8.200每天13:00-17:00禁止上网
重启服务后看下效果
哈~现在一个都不能访问了
还可以加星期几,里面很多实例,大家自己看看吧
客户端192.168.8.200周六周日下午13:00-17:00允许上网
OK~
加快访问速度,节约通信带宽
防止内部主机受到攻击
限制用户访问,完善网络管理



















acl list3 dstdomain .163.com,不能忘记加上".",正是它指出以此域名结尾的所有主机都不可访问,否则会导致不能访问163.com,而可以访问[url]www.163.com[/url]等哈~






















标签:
Squid,服务器配置
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com
暂无“Linux服务器架设笔记 Squid服务器配置”评论...
更新日志
2025年02月24日
2025年02月24日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]