linux系统下终端proxy代理配置

时间:2019-10-09
本文章向大家介绍linux系统下终端proxy代理配置,主要包括linux系统下终端proxy代理配置使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、前言

1、工作中有时会遇到需要翻墙下载软件的问题,这个时候就用到了正向代理。
2、正向代理服务器端的配置比较简单,这里不在重复说明,想了解的可以看作者的另一篇文章《nginx正向代理配置》,这里只对终端代理的配置进行说明。

二、终端代理配置

  • 代理变量的配置
    环境变量 描述 值示例
    http_proxy 为http变量设置代理,不填开头默认以http协议传输 10.20.56.32:8000
    user:pass@192.168.31.10:8080
    socks5://10.20.48.254:1080
    https_proxy 为https变量设置代理 同上
    ftp_proxy 为ftp变量设置代理
    同上
    socket_proxy 为socket变量设置代理 同上
    all_proxy 全部变量设置代理,配置了这个变量,上面的就不用设置了。
    同上
    no_proxy 1、无需代理的主机或域名;
    2、可以使用通配符;
    3、多个的时候,使用","号分割; .abc.com,10...,192.168..,*.local,localhost,127.0.0.1
  • 变量的设置方法
    1、在 /etc/profile文件
    2、在 ~/.bashrc
    3、在 /etc/profile.d/文件夹下新建一个文件xxx.sh
    写入如下配置:
export proxy="http://10.20.56.32:8000"
export http_proxy=$proxy
export https_proxy=$proxy
export ftp_proxy=$proxy
export no_proxy="localhost, 127.0.0.1, ::1"
  • 取消设置的方法
shell> unset http_proxy
shell> unset https_proxy
shell> unset ftp_proxy
shell> unset no_proxy

三、日积月累

  • 配置yum单独代理
shell> echo "proxy=http://10.20.57.32:8080/" >> /etc/yum.conf
  • php-fpm默认不加载系统的http/https proxy环境变量修改方法
# 添加php-ftpm关于env的如下配置,然后重启php-fpm服务。
env[http_proxy] = "http_proxy=http://1.1.1.1:8082" 
env[https_proxy] = "https_proxy=http://1.1.1.1:8082"
env[no_proxy] = "a.test.com,127.0.0.1,2.2.2.2"
  • subversion代理服务器配置
# 修改$HOME/.subversion/servers文件,在此文件的[global]段加上:
http-proxy-host = 192.168.1.1
http-proxy-port = 8080 
http-proxy-username = 91donkey
http-proxy-password = 123456 
  • 其他支持http/https正向代理的proxy软件
    nginx
    tinyproxy(简单,支持http/https协议)
    squid(稳定简单,支持http/https协议)
  • squid 3.x正向代理proxy配置
shell> cat /etc/squid/squid.conf
http_access allow all
http_port 8443
cache deny all

原文地址:https://www.cnblogs.com/91donkey/p/11640079.html