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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM