zoukankan      html  css  js  c++  java
  • 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

    本博客文章绝大多数为原创,少量为转载,代码经过测试验证,如果有疑问直接留言或者私信我。
    创作文章不容易,转载文章必须注明文章出处;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。
  • 相关阅读:
    android添加群组源码
    onItemClickListener不起作用解决办法2(原创)
    Android中layout过程详解
    android上一些方法的区别和用法的注意事项 (转载)
    Android中mesure过程详解
    AlertDialog dismiss 和 cancel方法的区别
    按Notification 回到正在运行的activity
    android添加联系人源码
    Use Eclipse
    数据区的内存模型
  • 原文地址:https://www.cnblogs.com/passedbylove/p/13541740.html
Copyright © 2011-2022 走看看