Centos7 下代理配置
对于提供服务的服务器来说,一般都配置在内网环境中,而在内网下公司处于安全的考虑,一般不开放外网的访问权限。这时如果想要访问外网,一般需要配置公司提供的代理服务器再进行使用。下面介绍几种配置代理的方法:
添加代理
方式一:在 /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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了