Ubuntu18.04安装http代理,为apt设置更新代理


背景

笔者租赁了华为云服务器,其中两台没有弹性IP,不能连接互联网,限制需要在能上网的开一个http代理,

以供其他不能上网的使用(apt /apt-get需要http代理,否则无法更新)。

在代理服务器(192.168.0.83)执行以下命令

安装tinyproxy包
sudo apt-get update
sudo apt-get install tinyproxy

编辑配置文件

vim /etc/tinyproxy/tinyproxy.conf
#修改端口为10838Port 10838
#只允许指定网段登录
Allow 192.168.0.0/24

设置默认启动

sudo service tinyproxy start

运行及重启

#重启
sudo service tinyproxy restart
#启动
sudo service tinyproxy start

测试是否启动成功(以下说启动成功)

lsof -i:10838

 

 

登录需要上网代理的服务器

vim ~/.bashrc
#shift+G到尾部,添加以下代码
export HTTPS_PROXY="http://192.168.0.83:10838"
export HTTP_PROXY="http://192.168.0.83:10838"
export https_proxy="http://192.168.0.83:10838"
export http_proxy="http://192.168.0.83:10838"

 

使配置生效

source ~/.bashrc

测试是否有效

apt update成功

参考:

https://blog.csdn.net/qq_27047075/article/details/104164043

https://www.cnblogs.com/andrewwang/p/9293031.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM