背景

笔者租赁了华为云服务器,其中两台没有弹性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

posted on 2020-08-21 16:30  你不知道的浪漫  阅读(2644)  评论(0编辑  收藏  举报