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