proxy - 代理设置 shell



---环境临时

export http_proxy=http://h.htmltoo.com:7778

export https_proxy=http://h.htmltoo.com:7778

export no_proxy=localhost,127.0.0.1,::1

-解除

unset  http_proxy

unset  https_proxy

unset  no_proxy


---Dockerfile

ENV http_proxy http://h.htmltoo.com:7778

ENV https_proxy http://h.htmltoo.com:7778

ENV no_proxy localhost,127.0.0.1,::1


---Docker Compose

environment:

  - HTTP_PROXY=http://g.htmltoo.com:7778

  - HTTPS_PROXY=http://g.htmltoo.com:7778



---docker run

-e  HTTP_PROXY="http://h.htmltoo.com:7778"  -e  HTTPS_PROXY="http://h.htmltoo.com:7778"  -e  NO_PROXY="localhost,127.0.0.1"


---Git

git config --global http.proxy 'http://h.htmltoo.com:7778'

git config --global https.proxy 'http://h.htmltoo.com:7778'

git config --global ssh.proxy  'http://h.htmltoo.com:7778'

-权限

git config --global http.proxy http://username:password@h.htmltoo.com:7778

-取消

git config --global –unset http.proxy

git config --global –unset https.proxy

git config --global –unset ssh.proxy

-查看设置

git config --get http.proxy

git config --get https.proxy

git config --get ssh.proxy


---wget 代理设置

-设置代理;

echo 'https_proxy=http://127.0.0.1:7890' | tee -a /etc/wgetrc

echo 'http_proxy=http://127.0.0.1:7890' | tee -a /etc/wgetrc

echo 'ftp_proxy=http://127.0.0.1:7890' | tee -a /etc/wgetrc

echo '#check_certificate = off' >> ~/.wgetrc

-取消代理;

vim /etc/wgetrc # 编辑wgerrc文件删除或注释代理设置;


---curl 代理设置

-设置代理;

echo 'proxy = "http://127.0.0.1:7890"' >> ~/.curlrc

echo '#insecure' >> ~/.curlrc

-取消代理;

vim ~/.curlrc # 编辑curlrc文件删除或注释代理设置;


---pip 代理设置

pip3 install --proxy http://h.htmltoo.com:7778  package_name

pip3 install --proxy http://user:password@h.htmltoo.com:7778 package_name


---环境变量设置

-设置代理;

echo 'export https_proxy="http://h.htmltoo.com:7778"' >> ~/.bashrc

echo 'export http_proxy=$https_proxy' >> ~/.bashrc

echo 'export ftp_proxy=$https_proxy' >> ~/.bashrc

echo 'export proxy=$https_proxy' >> ~/.bashrc

echo 'export HTTPS_PROXY=$https_proxy' >> ~/.bashrc

echo 'export HTTP_PROXY=$https_proxy' >> ~/.bashrc

echo 'export FTP_PROXY=$https_proxy' >> ~/.bashrc

echo 'export PROXY=$https_proxy' >> ~/.bashrc

-取消代理;

vim ~/.bashrc # 编辑.bashrc文件删除或注释代理设置;


---apt 代理设置

-设置代理;

echo 'Acquire::http::proxy "http://127.0.0.1:7890";' | tee -a /etc/apt/apt.conf

echo 'Acquire::https::proxy "https://127.0.0.1:7890";' | tee -a /etc/apt/apt.conf

-取消代理;

vim /etc/apt/apt.conf # 编辑apt.conf文件删除或注释代理设置;


-设置代理;

mkdir /etc/systemd/system/docker.service.d

echo '[Service]' | tee -a /etc/systemd/system/docker.service.d/http-proxy.conf

echo 'Environment="HTTP_PROXY=http://127.0.0.1:7890"' | tee -a /etc/systemd/system/docker.service.d/http-proxy.conf

systemctl daemon-reload

systemctl restart docker

-取消代理;

vim /etc/systemd/system/docker.service.d # 编辑docker.service.d文件删除或注释代理设置;


签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回