#####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.
站点屏蔽
[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.
[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.
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
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主机轮换服务)