EndSound's Life

【技術】Linux使用proxy

最近在安裝環境時遇到yum安裝時,當鏡像使用某些domain因被擋,而造成timeout以至於安裝失敗,需要proxy來繞過。

只在此session生效

$ export http_proxy=http://<host>:<port>
$ export https_proxy=https://<host>:<port>

適用於特定使用者

$ echo "export http_proxy=http://<host>:<port>" >> ~/.bashrc
$ echo "export https_proxy=https://<host>:<port>" >> ~/.bashrc

適用於全部的使用者

$ echo "export http_proxy=http://<host>:<port>" >> /etc/profile
$ echo "export https_proxy=https://<host>:<port>" >> /etc/profile

適用於yum

$ vim /etc/yum.conf
proxy=http://<host>:<port>

當proxy需要使用者認證時則在<host>前加上使用者資訊

http://<user>:<password>@<host>:<port>

參考:
Linux 使用全域 Proxy 上網 (with only apt/yum)

發表迴響