For some well-known reasons, it is necessary to set up a proxy to access certain URLs. The settings for the terminal are slightly different from those for git.
1. Mac proxy settings
Open the .bash_profile file
vi .bash_profile
Copy the following to the end of the file:
function proxy_off(){
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
echo -e "已关闭代理"
curl cip.cc
}
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:19180"
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
echo -e "已开启代理"
curl cip.cc
}
Among them, 19180 is the proxy port. Then the configuration takes effect
source .bash_profile
Turn on proxy
AdministratordeMacBook-Air:ios administrator$ proxy_on
已开启代理
IP : 172.104.78.245
地址 : 日本 东京都 品川区
运营商 : linode.com
数据二 : 日本东京都品川区 | Linode
数据三 : 日本东京都东京
URL : http://www.cip.cc/172.104.78.245
AdministratordeMacBook-Air:ios administrator$
Turn off the proxy command: proxy_off
2. git proxy settings
Git setting the proxy is relatively simple:
git config --global http.proxy http://127.0.0.1:19180
git config --global https.proxy https://127.0.0.1:19180
Among them, 19180 is the proxy port.
Cancel the proxy as follows:
git config --global --unset http.proxy
git config --global --unset https.proxy