前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS7下代理配置

CentOS7下代理配置

作者头像
院长技术
发布2020-11-05 14:36:01
1.1K0
发布2020-11-05 14:36:01
举报

对于提供服务的服务器来说,一般都配置在内网环境中,而在内网下公司处于安全的考虑,一般不开放外网的访问权限。这时如果想要访问外网,一般需要配置公司提供的代理服务器再进行使用。下面介绍几种配置代理的方法:

添加代理

方式一:在 /etc/environment 下进行配置

/etc/environment 添加代理服务的内容:

# 通过自己搭建账号密码的代理服务器
http_proxy="http://username:password@proxysrv:8080/"
https_proxy="https://username:password@proxysrv:8080/"
ftp_proxy="ftp://username:password@proxysrv:8080/"
no_proxy=".mylan.local,.domain1.com,host1,host2"

# 通过公司提供
export http_proxy=http://proxy.esl.cisco.com:80/
export https_proxy=https://proxy.esl.cisco.com:80/
ftp_proxy=https://proxy.esl.cisco.com:80/
export http_proxy
export https_proxy
export ftp_proxy

方式二: /etc/profile 下添加:

export http_proxy=http://proxy.esl.cisco.com:80/
export https_proxy=https://proxy.esl.cisco.com:80/
ftp_proxy=https://proxy.esl.cisco.com:80/
export http_proxy
export https_proxy
export ftp_proxy

方式三:使用函数,动态添加:

# /.bashrc
# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://PROXY_SERVER:PORT"
}
# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
}

在配置后使用 source 命令对应

查询配置的代理

 env | grep -i proxy

临时删除代理

unset http_proxy
unset https_proxy
unset ftp_proxy
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 添加代理
  • 查询配置的代理
  • 临时删除代理
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档