Squid配置

来源:互联网 发布:mac 强制退出 编辑:程序博客网 时间:2024/05/19 13:59

                                       普通squid代理服务器

http_port 192.168.10.1:3128

      开启服务的ip和端口

visible_hostname 192.168.10.1

acl innet src 192.168.10.0/24

      定义一个叫做innet的acl列表,代表192.168.10.0网段的用户群体

acl all src 0.0.0.0/0.0.0.0

      定义acl列表all代表来自所有客户机的群体

reply_body_max_size 10480000 allow all

      下载数据大小最大值

http_access allow innet

      允许innet列表

http_access deny all

      拒绝all列表

access_log/var/log/squid/access.log

      日志路径

cache_dirufs /var/spool/squid 100 16 256

      缓存100M,16个目录,每个目录256个文件

 

 

配置透明代理

在二层和三层之间使用iptables将数据包完好无损的重定向到3128端口

 

1、修改squid.conf

      http_port192.168.10.1:3128 transparent

           开启透明代理

2、squid –kreconfig

           重新加载配置

3、添加iptables规则,把内部的http请求重定向到3128端口

      iptables–t nat –I PREROUTING –i eth0 –s 192.168.10.0/24 –p tcp –dport 80 –j REDIRECT –to3128

      PREROUTING   数据刚刚进入网卡改变方向时

      -i进入接口

      -s来源网段

4、内部用户不需要在浏览器中设置代理,只需要设置网关

 

配置squid反向代理

修改squid.conf文件

http_port 200.168.10.1:80 vhost

      vhost虚拟80端口

cache_peer 192.168.10.2 parent 80 0originserver weight=5 max-conn=30

      0不去用旁边或上一的squid代理服务器

cache_peer 192.168.10.3 parent 80 0originserver weight=5 max-conn=30

cache_peer 192.168.10.4 parent 80 0originserver weight=5 max-conn=30

cache_peer 192.168.10.5 parent 80 0originserver weight=1 max-conn=8

 

反向代理虚拟主机映射

http_port 200.168.10.1:80 vhost

cache_peer 192.168.10.2 parent 80 0originserver name=a

cache_peer 192.168.10.2 parent 80 0originserver name=b

cache_peer_domain a www.lamp.com

cache_peer_domain b www.web.com

cache_peer_access a allow all

cache_peer_access b allow all