学习LINUX的第17天

一、使用Squid部署代理缓存服务

       yum install squid

       1.正向代理

          标准正向代理:           vim /etc/squid/squid.conf

                                             http_port 10000                                  #原有得3128端口改成10000,

                                             semanage port -a -t squid_port_t -p tcp 10000

                                             semanage port -l | grep squid_port_t

         ACL访问控制:            vim /etc/squid/squid.conf                   

                                             acl client src 192.168.10.20                                      #只允许IP为192.168.10.20 的客户端使用服务器上的squid服务程序提供的代理服务,禁止其余所有的主机代理请求

                                             http_access allow client

                                             http_access deny all

                                             acl deny_keyword url_regex -i linux                         #禁止所有客户端访问网址中包含linux关键词的网站

                                             http_access deny deny_keyword

                                             acl deny_url url regex http://www.abc.com             #禁止所有客户端访问某个特定的网站

                                             http_access deny deny_url

                                             acl badfile urlpath_regex -i \.rar$ \.avi$                   #禁止下载以.rar和.avi结尾的文件

                                             http_access deny badfile

           透明正向代理

            反向代理:             一般网站都禁止了反向代理功能,开启了CDN可避免这种行为。

                                          vim /etc/squid/squid.conf

                                          http_port 桥接网卡IP地址:80 vhost

                                          cache_peer 网站源服务器IP地址 parent 80 0 originserver

           image.png

image.png


猜你喜欢

转载自blog.51cto.com/15047572/2621764