ubuntu24 設(shè)置網(wǎng)絡(luò)代理

apt設(shè)置代理
打開apt代理配置文件

vi /etc/apt/apt.conf.d/proxy.conf

添加如下代理信息:

Acquire::http::Proxy "http://username:password@proxy-server-ip:8181/";
Acquire::https::Proxy "https://username:password@proxy-server-ip:8182/";

備注:使用export設(shè)置代理對apt無效

curl代理設(shè)置
直接在命令中加代理參數(shù),具體如下:

curl -x "http://user:pwd@127.0.0.1:1234" "http://httpbin.org/ip"
curl --proxy "http://user:pwd@127.0.0.1:1234" "http://httpbin.org/ip"

此外,在 環(huán)境變量中設(shè)置臨時設(shè)置代理:

# 設(shè)置 http proxy
export http_proxy="http://user:pwd@127.0.0.1:1234"
# 設(shè)置 https proxy
export https_proxy="http://user:pwd@127.0.0.1:1234"
取消 http,https 代理


unset http_proxy
unset https_proxy

或者在配置文件(如.bashrc)中配置代理

# 設(shè)置 http proxy
export http_proxy="http://user:pwd@127.0.0.1:1234"
# 設(shè)置 https proxy
export https_proxy="http://user:pwd@127.0.0.1:1234"

對curl同樣生效

docker設(shè)置代理
Docker代理配置

git設(shè)置代理
git配置網(wǎng)絡(luò)代理

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容