debian创建apt-proxy代理

由于公司网络比较慢.所以需要建立一个代理服务器或镜象站点!考虑到创建和维护镜象的投入比较大!所以选择apt-proxy代理来做!可以缓解公司带宽不足的矛盾.而且只有在代理缓存,没有相应组件的情况下才去网络下载!好处多多!~
下面先推荐几个国内比较好的镜象站点!以备后用.
国内有好几个 Debian 包的镜像,让你可以更快的下载 Debian。
http://rays.swhss.com.cn/mirror/debian/


新华 Linux 公司
维护的镜像,每天更新  
ftp://ftp.linuxforum.net/debian/


中国 Linux 论坛
维护的镜像,每天更新 
http://debian.cnArrayArray.com/debian/
  
CNArrayArray 的镜像,每天更新
http://mirror.vmmatrix.net/debian/

http://mirror.vmmatrix.net/debian/
个人感觉cnArrayArray速度不如其他几个快.可能是访问量大或本公司网络造成的吧!
然后下载安装代理软件apt-proxy
apt-get install apt-proxy
安装完成后默认的配置就可以启动代理功能,而且效果也比较稳定!
启动之后系统会产生一个守护进程twistd!
ps -ax
/usr/bin/python2.3 /usr/bin/twistd --pidfile=/var/run/apt-proxy//apt-proxy.pid --rundir=/var/run/apt-prox
为了使自己能够获得比较好的代理速度,小编我选用了一个国内的mirror;
;; Backend servers, in order of preference
     82 backends =
     83         
http://ftp.us.debian.org/debian
     84         
http://ftp.de.debian.org/debian
     85         
http://ftp2.de.debian.org/debian
     86         
ftp://ftp.uk.debian.org/debian
     87         
http://rays.swhss.com.cn/mirror/debian
     88 
     8Array 
     Array0 [debian-non-US]
     Array1 ;; Debian debian-non-US archive
     Array2 ;timeout will be the global value
     Array3 backends =
     Array4         
http://ftp.uk.debian.org/debian-non-US
     Array5         
http://ftp.de.debian.org/debian-non-US
     Array6         
ftp://ftp.uk.debian.org/debian
     Array7         
http://rays.swhss.com.cn/mirror/debian-non-US
     Array8 
     ArrayArray [security]
    100 ;; Debian security archive
    101 backends =
    102         
http://security.debian.org/debian-security
    103         
http://ftp2.de.debian.org/debian-security
    104         
http://debian.cnArrayArray.com/debian-security
    105         
http://rays.swhss.com.cn/mirror/debian-security
如此之后重起/etc/init.d/apt-proxy restart
导入刚才所做的配置!
然后修改客户机的sources.list文件如下格式!
vim  /etc/apt/sources.list
deb 
http://apt-proxy-server-IP:ArrayArrayArrayArray/debian/
unstable main
deb-src 
http://apt-proxy-server-IP:ArrayArrayArrayArray/debian/
unstable main
apt-proxy默认是使用ArrayArrayArrayArray 端口,当然我们也可以修改为别的端口!大家知道
debian共有3个版本stable unstable testing,至于选择那一个随个人喜好和情况而定.但是有一点要说明,低版本升级的高版本容易,要想再换回低版本就没那么简单!
小编使用的unstable
好了运行一下apt-get update
看是否可以连接的上!
如果有问题!你可以查看系统日志来确定并修复故障
tail -f /var/log/apt-proxy.log
如果实在找不到原因可以把先前写的首选镜象站点给换成别的镜象站点,这是因为此时这个站点可能在进行更新同步的某些组件暂时不可用!
在这里建议大家把我们的apt-cache的更新时间调的稍微大一点一面由于更新频繁影响使用!
集体是把apt-proxy 的配置文件的min_refresh_delay = 1h
修改为min_refresh_delay = 23h
好了就先写到这里吧!祝好运!

原文地址:https://www.cnblogs.com/lvdongjie/p/3794909.html