apt更新时针对不同网址设置代理
Tofloor
poster avatar
tonyhao
deepin
2017-04-19 19:18
Author
原文地址
https://www.findhao.net/easycoding/1925
Introduction
因为使用了一些软件,在apt-get update时,总是要用proxychains4在apt外面挂上一层代理,有些麻烦,所以想apt有没有针对不同网址的代理功能。
网上的资料很多是设置apt全局代理的,在vickycq的帮助下,找到了方法。
设置代理文件
创建文件/etc/apt/apt.conf.d/01proxy,内容如下所示:
Acquire::http:roxy::mega.nz "http://127.0.0.1:1081";
通过以上设置,apt更新时,对mega.nz网址的访问,将通过127.0.0.1:1081端口,走http流量访问。
对socks代理的支持
查阅资料,好像上面的代理不支持socks,尽管网上很多人的回答里,都有socks的部分内容。测试也不支持。
因此使用polipo这个非常轻量级的软件进行转发。
poliposudo apt-get install polipo
向默认的配置文件/etc/polipo/config里添加如下内容:
# This file only needs to list configuration variables that deviate# from the default values.  See /usr/share/doc/polipo/examples/config.sample# and "polipo -v" for variables you can tweak and further information.logSyslog = truelogFile = /var/log/polipo/polipo.log# 下面是添加的部分proxyAddress = "0.0.0.0"proxyPort = 1081socksParentProxy = "127.0.0.1:1080"socksProxyType = socks5
表示转换socks 1080的代理为http 1081代理。
Reference
Convert Socks Proxy To Http Proxy: Using Polipo
[如何针对源里不同地址使用不同代理](https://forums.debiancn.org/t/topic/556)
Is SOCKS4/5 supported by apt?
Reply Favorite View the author
All Replies

No replies yet