linux学习之squid

#####squid基本配置######
1.定义
 squid是一个缓存Internet数据的软件,其接受用户用户的下载申请。对于web用户来说,squid是一个高性能的代理缓存服务器。
2.访问控制(正向代理)
[root@foundation66 ~]# yum install squid -y  ##安装squid服务
[root@foundation66 ~]# netstat -antlpe | grep squid  ##查看是否由squid进程
[root@foundation66 ~]# systemctl restart squid
[root@foundation66 ~]# netstat -antlpe | grep squid  ##进程3128为squid服务
tcp6       0      0 :::3128                 :::*                    LISTEN      0          175604     14485/(squid-1)     

[root@foundation66 ~]# vim /etc/squid/squid.conf  ##squid配置文件
 57 # And finally deny all other access to this proxy
 58 http_access allow all                         ##允许所有主机访问
 59
 60 # Squid normally listens to port 3128
 61 http_port 3128                                ##端口
 62
 63 # Uncomment and adjust the following to add a disk cache directory.

 64 cache_dir ufs /var/spool/squid 100 16 256     ##代理服务器最多可以缓存100M,16个一级目录,256个二级目录


客户端测试

浏览器中设置网络network-settings-manaual-主机ip-3128


在浏览器写入要查看的网站





站点屏蔽
[root@foundation66 ~]# vim /etc/squid/squid.conf
 52 acl badurl dst www.baidu.com      ##仅拒绝www.baidu.com的访问,但不拒绝百度其他站点
 53 http_access deny badurl
 54 http_access allow localnet
 55 http_access allow localhost
 56
 57 # And finally deny all other access to this proxy
 58 http_access allow all
 59
 60 # Squid normally listens to port 3128
 61 http_port 3128
 62
 63 # Uncomment and adjust the following to add a disk cache directory.

 64 cache_dir ufs /var/spool/squid 100 16 256


客户端测试






[root@foundation66 ~]# vim /etc/squid/squid.conf
 52 acl badurl dstdomain .baidu.com               ##拒绝以.baidu.com结束的所有站点
 53 http_access deny badurl
 54 http_access allow localnet
 55 http_access allow localhost
 56
 57 # And finally deny all other access to this proxy
 58 http_access allow all
 59
 60 # Squid normally listens to port 3128
 61 http_port 3128
 62
 63 # Uncomment and adjust the following to add a disk cache directory.

 64 cache_dir ufs /var/spool/squid 100 16 256


客户端测试



4.反向代理加速web
[root@localhost ~]# rpm -qa | grep httpd  ##查询主机上是否安装httpd服务
[root@localhost ~]# yum install squid -y  ##安装squid服务

[root@localhost ~]# vim /etc/squid/squid.conf##修改配置文件234和66主机轮叫加快速率
 59 http_port 80  vhost vport    
 60 cache_peer 172.25.254.234 parent 80 0 no-query originserver  name=web1  round-robin
 61 cache_peer 172.25.254.66  parent 80 0 no-query originserver  name=web2  round-robin
 62 cache_peer_domain www.westos.com  web1 web2
 63 # Uncomment and adjust the following to add a disk cache directory.
 64 cache_dir ufs /var/spool/squid 100 16 256
 
[root@localhost ~]# vim /etc/hosts
172.25.254.134 www.westos.com





测试机为134

在浏览器输入www.westos.com显示轮叫效果(234和66主机轮换服务)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值