zoukankan      html  css  js  c++  java
  • squid 普通代理,透明代理,和方向代理简解

    /*    
                    @author:luowen
                    @time:2013-08-09
                    @desc:squid代理服务简介      
                [squid]代理服务器
                    [普通代理]
                        1.安装squid yum install squid*
                        2.配置squid /etc/squid/squid.conf
                            http_port 192.168.10.1:3128  //代理服务器的ip地址
                            cache_mem 64MB //缓存大小
                            maximum_object_size 4096KB //缓存里的一个最大的对象
                            reply_body_max_size 10480000 allow all //用户下载最大限制
                            access_log /var/log/squid/access.log //启动日志,利于排除
                            visible_hostname 192.168.10.1     //代理服务器显示名称
                            cache_dir_ufs /var/spool/squid 100(大小M) 16(一级目录) 256(每个一级里面有二级目录) //缓存池的设置
                            acl innet src 192.168.10.0/24 //squid address access list
                            acl all src 0.0.0.0/0.0.0.0
                            http_access allow innet //acl列表 innet 列表访问
                            http_access deny all //acl列表 all都过滤掉
                    [透明代理]
                            1.原理:数据访问squid服务器是,squid服务器通过iptables在过路由层的时候,认为的将数据放到squid的3128端口的里面(从定向),squid在出去代理
                            2.配置
                                http_port 192.168.10.1:3128 transparent
                                重新加载
                            3.借助iptables重定向到squid的3128端口上去
                                iptables -t nat -I PREROUTING -i eth0 -s 192.168.10.0/24 -p tcp --dport 80 -j REDIRECT --to 3128
                            4.设置网关为squid服务器ip地址
                    [方向代理]
                            1.原理:squid开放一个虚拟的80端口,接受数据到squid,squid去代理
                                squid第一个网卡是一个公网ip,squid第二块网卡和很多的私网ip构成一个私网.
    
                            2.配置
                                http_port 200.168.10.1:80 vhost
                                cache_peer 192.168.10.2 parent 80 0 riginserver weight=5 max-conn=30
                                cache_peer 192.168.10.3 parent 80 0(0表示squid服务的级联江西到北京有很多的squid,可以共用squid的缓存) riginserver weight=5 max-conn=30
                                cache_peer 192.168.10.4 parent 80 0 riginserver weight=5 max-conn=30
                                cache_peer 192.168.10.5 parent 80 0 riginserver weight=5 max-conn=30
                                注:私网的服务器是一个集群状态,只有一个作用
                            3.192.168.10.5放了两个网站,通过虚拟主机技术
                                cache_peer 192.168.10.5 parent 80 0 riginserver name = a weight=5 max-conn=30
                                cache_peer 192.168.10.5 parent 80 0 riginserver name = b weight=5 max-conn=30
                                cache_peer_domain a www.lamp.com
                                cache_peer_domain b www.lamp2.com
                                cache_peer_access a allow all
                                cache_peer_access b allow all
                            
                    [配置demo]
                        #http_port 200.168.10.1:80 vhost
                        #visible_hostname 200.168.10.1
                        #cache_dir ufs  /var/spool/squid/ 10 16 100 
                        #acl innet src 192.168.10.0/24
                        #acl all src 0.0.0.0/all
                        #http_access allow innet
                        #http_access deny other
                        #http_access allow all 
                        #cache_peer 192.168.10.2 parent 80 0 originserver weight=2 max-conn=30 name=a
                        #cache_peer 192.168.10.2 parent 80 0 originserver weight=2 max-conn=30 name=b
                        #cache_peer_domain a vhost1.lw
                        #cache_peer_domain b vhost2.lw
                        #cache_peer_access a allow all
                        #cache_peer_access b allow all
  • 相关阅读:
    ASP.NET Core: What I learned!
    Entity Framework Core with GraphQL and SQL Server using HotChocolate
    Angular 9 Chart.js with NG2-Charts Demo
    POST调用WCF方法-项目实践
    项目实战-登录速度优化笔记
    MP4视频流base64数据转成Blob对象
    使用Vue+ElementUI实现前端分页
    JS端实现图片、视频时直接下载而不是打开预览
    Dynamic CRM工作流流程实战
    Dynamic CRM插件调试与单元测试
  • 原文地址:https://www.cnblogs.com/luowen/p/3248641.html
Copyright © 2011-2022 走看看