手机版
你好,游客 登录 注册
背景:
阅读新闻

Squid2.7+iptables+透明代理+sarg

[日期:2012-06-24] 来源:Linux社区  作者:linux521 [字体:大 中 小]

1、squid 安装

  1. wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.18-20111219-r10418.tar.gz  
  2. tar xvf squid-3.1.18-20111219-r10418.tar.gz  
  3. cd squid-3.1.18-20111219-r10418  
  4. ./configure --prefix=/usr/local/squid   \  
  5. --enable-epoll   \  
  6. --disable-internal-dns  \  
  7. --enable-storeio=aufs,diskd,ufs  \  
  8. --enable-default-err-languages=Simplify_Chinese  \  
  9. --enable-linux-netfilter    \  
  10. --enable-err-language=Simplify_Chinese  \  
  11. --enable-default-err-languages=Simplify_Chinese  \  
  12. --enable-arp-acl  \  
  13. --enable-snmp   \  
  14. --enable-async-io=90   \  
  15. --enable-cahce-digests        \  
  16. --enable-underscore    \  
  17. --enable-gnuregex    \  
  18. --enable-icmp  \
  19. --enable-kill-parent-hack  \ 
  20.  
  21. make&&make install
  22. groupadd squid
  23. useradd -g squid:squid squid
  24. mkdir -p /data/squid/logs
  25. chown -R squid /data/squid/
  26. chown -R squid /usr/local/squid

注: 1>--enable-epoll        //支持epoll非阻塞io模型
      2>--enable-default-err-languages=Simplify_Chinese  //默认的错误语言
      3>--enable-err-language=Simplify_Chinese   //支持错误代理
      4>--enable-arp-acl    //允许基于MAC地址的存取过滤
      5>--enable-snmp     //支持snmp
      6>--enable-async-io=90     //采用同步io提高性能,此值视具体配置情况而定
      7>--enable-cahce-digests     //允许缓存摘要,可以加快请求缓冲内容的速度(集群用)
      8>--enable-icmp       //icmp协议代理(默认不允许)
      9>--enable-linux-netfilter        //要想实现透明代理,启用linux netfilter支持
      10>--enable-async-io=180        //1G内存,并且是双核的选180,否则选100以下
 

squid配置

  1. ###########################squid.conf#######################  
  2. http_port 192.168.0.1:3128 transparent  
  3. cache_mem 100 MB   
  4. maximum_object_size 9000 KB       
  5. maximum_object_size_in_memory 6128 KB  
  6.  
  7. #dns_nameservers  202.106.0.20 8.8.8.8  
  8. cache_dir ufs /data/squid/cache 100 16 256   
  9. error_directory /usr/local/squid/share/errors/zh-cn  
  10.  
  11. acl nocache urlpath_regex cookie.*\.php *\.jsp *\.asp *\.pl *\.cgi   
  12. no_cache deny nocache       
  13.  
  14. acl audio urlpath_regex -i .torrent$ .avi$ .mp3$ .mp4$  
  15. http_access deny audio       
  16.  
  17. acl name url_regex -i    
  18. http_access deny name  
  19.  
  20. cache_access_log /data/squid/logs/cache_access.log  
  21. cache_log /data/squid/logs/cache.log  
  22. cache_store_log /data/squid/logs/cache_store.log  
  23.  
  24. acl localhost src 192.168.0.0/24  
  25. http_access allow localhost  
  26.  
  27. #acl all src 0.0.0.0/0.0.0.0  
  28. http_access deny all  
  29.  
  30. acl safe port 80 21 443 3128  
  31. http_access allow safe     
  32.  
  33. cache_effective_user squid  
  34. cache_effective_group squid   
  35. cache_mgr 103194669@qq.com  
  36. acl conncount maxconn 20  
  37.  
  38. visible_hostname LinuxProxyServer  
  39. icon_directory /usr/local/squid/share/icons  
  40.  
  41. ipcache_size 2024  
  42. ipcache_low 90  
  43. ipcache_high 95  
  44. fqdncache_size 2024  
  45. #######################squid.conf_END#########################  

配置文件是自己情况而定
 

  1. /usr/local/squid/sbin/squid -z 生成缓存目录  
  2. /usr/local/sbin/squid -NCd1  显示日志运行  
  3. /usr/local/sbin/squid  后台运行  
  4.  
  5. echo "/usr/local/sbin/squid" >> /etc/rc.local 
linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款