linux运维-squid

来源:互联网 发布:js代码攻击 编辑:程序博客网 时间:2024/05/16 12:47

1.squid正向代理
    在真机进行操作:
    yum install squid -y

    vim /etc/squid/squid.conf
        ##acl badurl dst www.baidu.com      ##访问不到www.baidu.com其他可以

        ##acl badurl dstdomain .baidu.com   ##所有的.baidu.com都访问不到
        ##http_access deny badurl       ##拒绝做badurl的代理
        http_access allow localnet      ##允许本机网络访问
        http_access allow localhost     ##允许本地主机访问

        # And finally deny all otheraccess to this proxy
        http_access allow all                           ##
允许所有人通过http访问

        # Squid normally listens to port3128
        http_port 3128                              ##
端口号为3128

        # Uncomment and adjust thefollowing to add a disk cache directory.
        cache_dir ufs /var/spool/squid 10016 256               ##访问缓存

        systemctl restart squid



   

测试:desktop
    firefox->edit->preferences->advanced->network->setting->manual:http:172.25.254.22port:3128

       
2.squid反向代理

    server:(关闭httpd服务)
    yum install squid -y

    vim /etc/squid/squid.conf
        http_access allow all
        cache_peer 172.25.254.122 parent80 0 no-query
        # Squid normally listens to port3128
        http_port 80 vhost vport
         
        # Uncomment and adjust thefollowing to add a disk cache directory.
        cache_dir ufs /var/spool/squid 10016 256

    systemctl restart squid
    测试:浏览器输入172.25.254.122可以访问到


\

3.squid访问多台服务器
    server:
    vim /etc/squid/squid.conf
        http_access allow all
        # Squid normally listens to port3128
        http_port 80 vhost vport
        cache_peer 172.25.254.122 parent80 0 no-query originserver name=web1 round-robin
        cache_peer 172.25.254.122 parent80 0 no-query originserver name=web2 round-robin
        cache_peer_domain www.westos.comweb1 web2
         
        # Uncomment and adjust thefollowing to add a disk cache directory.
        cache_dir ufs /var/spool/squid 10016 256


   

systemctl restart squid
    vim /etc/hosts
        172.25.254.122www.westos.com

原创粉丝点击