首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >npm安装在一个代理后面,但获得了Http Error=407 (第一线TMG需要授权)

问npm安装在一个代理后面,但获得了Http Error=407 (第一线TMG需要授权)
EN

Server Fault用户
提问于 2018-10-17 17:08:58
回答 1查看 5.5K关注 0票数 1

操作系统是MacOS,并且已经在网络首选项中设置了http(s)代理,但是在终端中运行npm install (npm是nodejs的包安装程序)时总是无法安装任何包,它会弹出错误407 Proxy Authentication Required。

因此,我安装了cntlm并应用了正确的配置。

下面是测试,似乎通过了(返回HTTP代码200):

代码语言:javascript
复制
cntlm -c /usr/local/etc/cntlm.conf -I -M http://registry.npmjs.org/vue
Password: 
Config profile  1/4... OK (HTTP code: 200)
----------------------------[ Profile  0 ]------
Auth            NTLMv2
PassNTLMv2      28B089518C6573274C6B9D83D0XXXXXX

当我运行npm i vue-cli -g时,cntlm确实收到了如下请求:

代码语言:javascript
复制
cntlm -c /usr/local/etc/cntlm.conf -f
Oct 15 15:12:29  cntlm[17646] <Info>: Cntlm ready, staying in the foreground
Oct 15 15:12:38  cntlm[17646] <Info>: Using proxy company-proxy:80
Oct 15 15:12:38  cntlm[17646] <Debug>: 127.0.0.1 GET http://registry.npmjs.org/nexe

但nodejs排除了以下例外情况:

代码语言:javascript
复制
npm i vue-cli -g
npm ERR! code E407
npm ERR! 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  ): vue-cli@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/****/.npm/_logs/2018-10-15T23_13_47_019Z-debug.log

这让我感到困惑:因为测试已经通过,但是为什么cntlm仍然无法连接到npmjs.org呢?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2018-10-17 20:49:02

最后找出解决方案:

  1. 不要使用纯文本密码(在#行的开头添加一个Password,如将Password XXX更改为#Password XXX)
  2. 改用PassLM、PassNT、PassNTLMv2 (看起来哈希值将再次阻止auth握手机制,这意味着您代表登录到Windows用户帐户的应用程序)。

默认的cntlm配置文件已经介绍了如何生成它们的步骤。

我的步骤如下:

  1. 执行cntlm -H -d your_domain -u your_username
  2. 然后提示密码,输入密码,然后按Enter键:

产出如下:

代码语言:javascript
复制
Password:
PassLM          F5314AF8A2DB16BDB7EE9FA6CFC5BC9A
PassNT          4EC02E0D65F8F0C1A9386C69CB6A2555
PassNTLMv2      28B089518C6573274C6B9D83D0EB8651 
  1. 将以上哈希值粘贴到配置文件中的相关字段。
  2. 保存,然后重新启动cntlm,它可以工作。
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/936001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档