配制过程分为以下几步:
1. 安装socat,在ubuntu下使用以下命令安装
- sudo apt-get install socat
sudo apt-get install socat
2. 编辑一个脚本文件,名字为git-proxy ,内容如下
- #!/bin/sh
- # Use socat to proxy git through an HTTP CONNECT firewall.
- # Useful if you are trying to clone git:// from inside a company.
- # Requires that the proxy allows CONNECT to port 9418.
- #
- # Save this file as gitproxy somewhere in your path
- # (e.g., ~/bin) and then run
- # chmod +x git-proxy
- # git config --global core.gitproxy git-proxy
- #
- #
- # Configuration. Common proxy ports are 3128, 8123, 8000.
- _proxy= 172.26.100.238
- _proxyport=64000
- exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path
# (e.g., ~/bin) and then run
# chmod +x git-proxy
# git config --global core.gitproxy git-proxy
#
#
# Configuration. Common proxy ports are 3128, 8123, 8000.
_proxy= 172.26.100.238
_proxyport=64000
exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
3. 将git-proxy放到一个目录下,如我将它放到/home/wilsonke/local/bin,并将该目录加入到PATH
- cp git-proxy /home/wilsonke/local/bin/
cp git-proxy /home/wilsonke/local/bin/
将该目录加入到PATH,加入以下内容到~/.bashrc,然后souce ~/.bashrc
- export PATH=$PATH:/home/wilsonke/local/bin
export PATH=$PATH:/home/wilsonke/local/bin
- source ~/.bashrc
source ~/.bashrc
4. 修改~/.gitconfig,加入以下行和代理
- [push]
- default = simple
- [user]
- name = wilsonke77
- email = 275156430@qq.com
- [core]
- editor = emacs
- gitproxy = git-proxy
- [https]
- proxy = http://wilson_ke:password@172.26.100.238:64000
- [http]
- proxy = http://wilson_ke:password@172.26.100.238:64000
[push]
default = simple
[user]
name = wilsonke77
email = 275156430@qq.com
[core]
editor = emacs
gitproxy = git-proxy
[https]
proxy = http://wilson_ke:password@172.26.100.238:64000
[http]
proxy = http://wilson_ke:password@172.26.100.238:64000
5. 下载转换协议文件connect.c,下载地址 点击
- gcc -o connect connect.c
gcc -o connect connect.c
将编译后的文件connect也拷贝到/home/wilsonke/local/bin下
6. 修改~/.ssh/config,加入以下行
- ProxyCommand /home/wilsonke/local/bin/connect -H 172.26.100.238:64000 %h %p
- Host github.com
- User 275156430@qq.com
- Port 443
- Hostname ssh.github.com
ProxyCommand /home/wilsonke/local/bin/connect -H 172.26.100.238:64000 %h %p
Host github.com
User 275156430@qq.com
Port 443
Hostname ssh.github.com
7.完成并测试
- git clone https://github.com/facebook/wangle
git clone https://github.com/facebook/wangle
如果能正常clone下来,则表示成功。
后记:很多开源项目同时可能还会用到wget来下载代码,同样,wget也要设置代理服务器
创建用户的~/.wgetrc文件中,添加如下内容:
- http_proxy = http://172.26.100.238:64000/
- ftp_proxy = http://172.26.100.238:64000/
- --proxy-user=wilson_ke
- --proxy-passwd=password
http_proxy = http://172.26.100.238:64000/
ftp_proxy = http://172.26.100.238:64000/
--proxy-user=wilson_ke
--proxy-passwd=password
完成了上述配置后,就可以成功编译facebook的项目proxygen
参考资料
http://blog.csdn.net/loveaborn/article/details/24575659