proxy代理通常是两种状况,一使用国外代理,一是公司局域网的proxy限制。html
二级代理主要是使用能够经过proxy上网的机器,再生成proxy服务,好处有三:node
可提供其余不能上外网的机器用linux
可避免proxy帐号泄露git
也避免proxy帐号更改时,须要大批量更改配置文件github
在PC机上搭建代理服务器cntlm。咱们的PC是windows2003,linux上的安装方式相似。官网docker
1 . 安装cntlmnpm
下载cntlm.exe 安装json
2 . 配置cntlm.ini文件ubuntu
进入安装目录,把cntlm.ini文件配置以下:
Username 域帐号 Domain china Password 密码 Proxy yourproxyServer:8080 Proxy yourproxyServer:8080 NoProxy localhost, 127.0.0.*, 10.* Listen yourpcIP:3128 Allow 0/0
3 . 生成NTLM值windows
执行 `cntlm.exe -c cntlm.ini -M http://www.google.com` ,http://www.google.com 可替换成任意的外网址。**按提示输入域帐号密码**
4 . 启动服务
把红框内容拷贝到cntlm.ini中,完整版以下:
Username 域帐号 Domain china Password 密码 Proxy yourproxyServer:8080 Proxy yourproxyServer:8080 NoProxy localhost, 127.0.0.*, 10.* Listen yourpcIP:3128 Allow 0/0 Auth NTLM PassNT 419386ED93C48D15FF169EF6370FEDEF PassLM 25C746715EB9633900E8C9A050E00176
启动cntlm服务`net start cntlm`
proxy地址为代理PC的IP地址:3128。下述提到的配置文件位置以ubuntu14.04为例,其余版本不肯定。
多数软件会默认读取环境变量中的http_proxy和https_proxy,先配置为全局变量。
在/etc/profile
中加入:
export http_proxy="http://yourcntlmIp:3128" export https_proxy="http://yourcntlmIp:3128" export ftp_proxy="http://yourcntlmIp:3128"
在/etc/apt/apt.conf
中加入:
Acquire::http::proxy "http://yourcntlmIp:3128"; Acquire::https::proxy "http://yourcntlmIp:3128";
若是内部有https限制 访问限制:
apt-get的镜像源在/etc/apt/source-list
文件中,记得把https
开头的镜像替换成有http
的
配置后需执行source /etc/profile
才可生效
npm是nodejs的一个软件管理工具
在/etc/profile
中加入:
export npm_config_proxy="http://yourcntlmIp:3128"
同理,需执行source /etc/profile
才可生效。注:npm的proxy有多种配置方式,详情见参考连接Npm的配置管理及设置代理。
https限制 :
npm的默认镜像是https://registry.npmjs.org/
,可将镜像源替换成http
或者国内镜像。替换方式:
npm config set registry http://registry.npmjs.org/ npm config set registry http://r.cnpmjs.org/
查看npm的当前镜像源,可以使用npm config list
查看。
注意! 若是你使用了网上的开源项目,在文档里直接执行npm install
安装,修改镜像源是不生效的! 此时,须要修改安装目录下的package.json
和npm-shrinkwrap.json
文件的resolved
字段。
例如:
{ "name": "meteor-dev-bundle", "version": "0.0.0", "dependencies": { "amdefine": { "version": "1.0.0", "from": "amdefine@>=0.0.4", "resolved": "https://registry.npmjs.org/npm-registry/amdefine/-/amdefine-1.0.0.tgz" }, ......
改为
{ "name": "meteor-dev-bundle", "version": "0.0.0", "dependencies": { "amdefine": { "version": "1.0.0", "from": "amdefine@>=0.0.4", "resolved": "http://registry.npmjs.org/npm-registry/amdefine/-/amdefine-1.0.0.tgz" }, ......
Tips: 若是安装包是在https://github 或者其余网站,则须要下载到本地,而后修改resolved
字段到local地址。
docker是一种容器,与虚拟机相似,可是更加轻巧。此处的proxy配置是dockerhub(与github相似,一个镜像仓库)的链接。
在/etc/default/docker
中加入:
export http_proxy='http://yourcntlmIp:3128' export https_proxy='http://yourcntlmIp:3128'
需重启docker服务才可生效,service docker restart
https限制
docker的源是http的…………
meteor 是nodejs的一个框架,依赖于npm install安装模块
在/etc/profile
中加入:要大写!
export HTTP_PROXY='http://yourcntlmIp:3128' export HTTPS_PROXY='http://yourcntlmIp:3128'
需执行source /etc/profile
才可生效
https限制
meteor在npm的基础上还加了本身的包管理。目前没有找到替换源的地方。须要meteor add
,都是使用离线下载哒!
整理下离线下载的步骤:
在官网搜索对应的package包
在package包的页面找到github所在的地址(在右边有个GitHub
按钮)
在github下载package包
在meteor的目录下建立jpackages目录,并把下载的包解压到该目录下
从package包的package.js文件中获取包的名称package-name
执行meteor add <package-name>