Squid:代理服务器
squid:www.squid-cache.org
SNAT
ICP:Internet Cache Protocol
代理Proxy:SNAT
反向代理reverse proxy:DNAT
CDN:Content Delivery Network
Proxy:Squid, Varnish, ATS, Nginx
squid:
软件包名:squid-2.6.STABLE6
服务名:squid
主程序:/usr/sbin/squid
配置目录:/etc/squid
主配置文件:/etc/squid/squid.conf
默认监听端口:3128
默认访问日志文件:/var/log/squid/access.log
常用配置项:
http_port 3128
cache_mem 64MB
maximum_object_size 4096KB
reply_body_max_size 10240000 allow all
access_log /var/log/squid/access.log squid
visibe_hostname proxy.test.com
cache_dir ufs /var/spool/squid 100 16 256
cache_dir ufs /var/spool/squid 100 16 256
ufs 缓存数据在存储格式
100 为缓存目录分配的磁盘空间(MB)
16 缓存空间的一组子目录个数
256 缓存空间的二级子目录
acl LAN src 192.168.0.0/24
acl WORKTIME time 08:00-18:00
http_access allow LAN WORKTIME
error_directory /usr/share/squid/errors/Simplify_Chinese
squid -k parse 检查语法
service squid restart
透明代理:
修改squid.conf配置文件
http_port 192.168.10.2:8080 transparent
添加iptables规则
iptables -F
iptables -F -t nat
iptables -P INPUT DROP
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3128
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -p udp --dport 53 -j MASQUERADE
#iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE(单用此条直接代理)
两种方案:
1、内部DNS
2、DNS SNAT
反向透明代理:
修改squid.conf配置文件
http_port 192.168.10.2:80 vhost
cache_peer 192.168.0.254 parent 80 0 originserver weight=1 max-conn=1000
压力测试:
http_load -parallel 200 -fetches 1000 file_name