首页 > 代码库 > squid第二层代理的安装配置

squid第二层代理的安装配置

1、编译源码

# tar -zxf squid-3.5.23.tar.gz


# cd squid-3.5.23


# ./configure --prefix=/usr/local/squid


# make && make install


2、编辑配置文件

/usr/local/squid/etc # cat squid.conf | grep -v "^#" | grep -v "^$"

cache_peer 192.168.1.100 parent 8099 0 no-query

http_access allow all

never_direct allow all

http_access allow all

http_port 3128

cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256

cache_access_log /usr/local/squid/var/logs/access.log

cache_log /var/squid/cache.log

coredump_dir /usr/local/squid/var/cache/squid

refresh_pattern ^ftp:           1440    20%     10080

refresh_pattern ^gopher:        1440    0%      1440

refresh_pattern -i (/cgi-bin/|\?) 0     0%      0

refresh_pattern .               0       20%     4320


配置说明:

cache_peer 192.168.1.100 parent 8099 0 no-query # 配置的上一层代理 IP是192.168.1.100 端口号是8099


http_access allow all #允许所有的用户通过代理进行http访问,在3.0版本之前还需要在这条配置之前添加一行acl all src 0.0.0.0/0.0.0.0,但是3.0版本后默认有了这条配置


never_direct allow all #所有请求转至上层代理


3、生成日志文件

# mkdir /var/squid

# touch /var/squid/cache.log

# chmod 777 /var/squid/cache.log


/usr/local # chmod -R 777 squid


4、重建缓存并启动服务

/usr/local/squid/sbin # ./squid -z

/usr/local/squid/sbin # 2017/03/07 16:07:33 kid1| Set Current Directory to /usr/local/squid/var/cache/squid

2017/03/07 16:07:33 kid1| Creating missing swap directories

2017/03/07 16:07:33 kid1| /usr/local/squid/var/cache/squid exists

2017/03/07 16:07:33 kid1| Making directories in /usr/local/squid/var/cache/squid/00

2017/03/07 16:07:33 kid1| Making directories in /usr/local/squid/var/cache/squid/01

2017/03/07 16:07:33 kid1| Making directories in /usr/local/squid/var/cache/squid/02

2017/03/07 16:07:33 kid1| Making directories in /usr/local/squid/var/cache/squid/03

2017/03/07 16:07:34 kid1| Making directories in /usr/local/squid/var/cache/squid/04

2017/03/07 16:07:34 kid1| Making directories in /usr/local/squid/var/cache/squid/05

2017/03/07 16:07:34 kid1| Making directories in /usr/local/squid/var/cache/squid/06


/usr/local/squid/sbin # ./squid start

/usr/local/squid/sbin # ps -ef | grep squid

root      7379     1  0 16:09 ?        00:00:00 ./squid start

nobody    7382  7379  1 16:09 ?        00:00:00 (squid-1) start

root      8724 20694  0 16:10 pts/1    00:00:00 grep squid


本文出自 “xiaoxiaozhou” 博客,请务必保留此出处http://xiaoxiaozhou.blog.51cto.com/4681537/1918540

squid第二层代理的安装配置