奔牛网>服务器>Linux服务器>>centos squid高匿代理服务器设置
2017年05月10日

centos squid高匿代理服务器设置

1.环境

 

 

操作系统:CentOS 6.8 IP:10.60.20.252 Squid版本:squid-3.1.10-20.el6_5.3.x86_64 SELINUX=disabled HTTP Service: stoped

 

 

2.安装

 

yum install squid -y chkconfig --level 35 squid on 

 

3.配置(vim /etc/squid/squid.conf,添加以下内容)
配置文件说明:

 

 

http_port 3128      //设置监听的IP与端口号
 cache_mem 64 MB      //额外提供给squid使用的内存,squid的内存总占用为 X * 10+15+“cache_mem”,其中X为squid的cache占用的容量(以GB为单位),                //比如下面的cache大小是100M,即0.1GB,则内存总占用为0.1*10+15+64=80M,推荐大小为物理内存的1/3-1/2或更多。
maximum_object_size 4 MB   //设置squid磁盘缓存最大文件,超过4M的文件不保存到硬盘
 minimum_object_size 0 KB   //设置squid磁盘缓存最小文件
 maximum_object_size_in_memory 4096 KB   //设置squid内存缓存最大文件,超过4M的文件不保存到内存
 cache_dir ufs /var/spool/squid 100 16 256   //定义squid的cache存放路径 、cache目录容量(单位M)、一级缓存目录数量、二级缓存目录数量
 logformat combined %&gt;a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}&gt;h" %Ss:%Sh        //log文件日志格式
 access_log /var/log/squid/access.log combined  //log文件存放路径和日志格式
 cache_log /var/log/squid/cache.log   //设置缓存日志
 logfile_rotate 60   //log轮循 60天
 cache_swap_high 95  //cache目录使用量大于95%时,开始清理旧的cache
 cache_swap_low 90   //cache目录清理到90%时停止。
 acl localnet src 192.168.1.0/24  //定义本地网段
 http_access allow localnet  //允许本地网段使用
 http_access deny all  //拒绝所有
 visible_hostname squid.david.dev  //主机名
 cache_mgr mchina_tang@qq.com  //管理员邮箱

 

 

需要添加的内容:

 

 

http_port 3128                  #端口 cache_mem 64 MB maximum_object_size 4 MB cache_dir ufs /var/spool/squid 100 16 256 access_log /var/log/squid/access.log acl localnet src 10.60.20.0/24       #定义本地网段 http_access allow localnet http_access deny all visible_hostname myserver01.lo #squid主机名 cache_mgr test@qq.com #邮箱 #以下是高匿的设置 request_header_access Via deny all request_header_access X-Forwarded-For deny all

 

 

4.初始化

 

[root@myserver01 var]# squid -z
2016/08/23 16:19:54| Creating Swap Directories 2016/08/23 16:19:54| /var/spool/squid exists 2016/08/23 16:19:54| /var/spool/squid/00 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/00
2016/08/23 16:19:54| /var/spool/squid/01 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/01
2016/08/23 16:19:54| /var/spool/squid/02 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/02
2016/08/23 16:19:54| /var/spool/squid/03 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/03
2016/08/23 16:19:54| /var/spool/squid/04 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/04
2016/08/23 16:19:54| /var/spool/squid/05 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/05
2016/08/23 16:19:54| /var/spool/squid/06 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/06
2016/08/23 16:19:54| /var/spool/squid/07 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/07
2016/08/23 16:19:54| /var/spool/squid/08 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/08
2016/08/23 16:19:54| /var/spool/squid/09 exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/09
2016/08/23 16:19:54| /var/spool/squid/0A exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0A 2016/08/23 16:19:54| /var/spool/squid/0B exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0B 2016/08/23 16:19:54| /var/spool/squid/0C exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0C 2016/08/23 16:19:54| /var/spool/squid/0D exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0D 2016/08/23 16:19:54| /var/spool/squid/0E exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0E 2016/08/23 16:19:54| /var/spool/squid/0F exists 2016/08/23 16:19:54| Making directories in /var/spool/squid/0F

 

 

5.启动Squid

 

/etc/init.d/squid start

 

6.测试



7、附录:各种代理方式的区别
顶(1)
踩(0)
最新评论