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

[[email protected] ~]# 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个二级目录

linux学习之squid

客户端测试

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

linux学习之squid

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

linux学习之squid




站点屏蔽
[[email protected] ~]# 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

linux学习之squid

客户端测试

linux学习之squid

linux学习之squid





[[email protected] ~]# 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

linux学习之squid

客户端测试

linux学习之squid

linux学习之squid

linux学习之squid


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

[[email protected] ~]# 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
 linux学习之squid
[[email protected] ~]# vim /etc/hosts
172.25.254.134 www.westos.com





测试机为134

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

相关文章:

  • 2021-11-23
  • 2021-06-13
  • 2021-10-18
  • 2022-12-23
  • 2021-11-05
  • 2022-02-23
  • 2022-01-01
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2021-09-22
  • 2021-11-06
  • 2021-09-20
  • 2021-12-25
相关资源
相似解决方案