swe*_*ere 5 openssl reverse-proxy squid npm
我们有一个带有 SSL 的 Squid 代理,使用自签名证书和 ca-bundle.cert。直到最近,NPM 安装在尝试安装时才开始失败
npm --registry https://registry.npmjs.org \ --proxy http://localhost:10080 --https-proxy http://localhost:10443 \ --ddd install express
产生错误 -
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/express failed,
reason: unable to verify the first certificate
Run Code Online (Sandbox Code Playgroud)
Squid 正在 Docker 中运行,其日志显示
NONE/200 0 CONNECT registry.npmjs.org:443 - HIER_DIRECT
Run Code Online (Sandbox Code Playgroud)
任何想法或指示将不胜感激。
我将“dns_v4_first on”添加到了squid.conf中,现在NPM错误消息是
npm verb node v8.9.3
npm verb npm v5.5.1
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
npm ERR! request to https://registry.npmjs.org/express failed, reason: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)
我发现 NPM 接受代理设置的异常行为。当代理设置为内联时,如下所示,它会返回 HTTP 503。
npm cache clear --force && rm -rf node_modules/
npm --strict-ssl=false --registry https://registry.npmjs.org
--proxy http://example-proxy.net:3339 --https-proxy http://example-proxy.net:3339
--ddd install express
Run Code Online (Sandbox Code Playgroud)
当仅设置代理而不设置 https 代理时,它可以工作!
npm cache clear --force && rm -rf node_modules/
npm --strict-ssl=false --registry https://registry.npmjs.org
--proxy http://example-proxy.net:3339
--ddd install express
Run Code Online (Sandbox Code Playgroud)
当在 shell 中设置代理而不是通过 npm 命令时,它可以工作!
export http_proxy=http://example-proxy.net:3339
export HTTPS_PROXY=http://example-proxy.net:3339
export https_proxy=http://example-proxy.net:3339
export HTTP_PROXY=http://example-proxy.net:3339
npm cache clear --force && rm -rf node_modules/
npm --strict-ssl=false --registry https://registry.npmjs.org
--ddd install express
Run Code Online (Sandbox Code Playgroud)
那么当同时设置 proxy 和 https-proxy 时,为什么 npm 命令会返回 HTTP 503 呢?
小智 3
看起来鱿鱼正在尝试通过 IPv6 在只有 IPv4 的主机上进行连接:
connect(14, {sa_family=AF_INET6, sin6_port=htons(443), inet_pton(AF_INET6, "2400:cb00:2048:1::6810:1b23", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 ENETUNREACH (Network is unreachable)
read(14, 0x7ffe450e1040, 65535) = -1 ENOTCONN (Transport endpoint is not connected)
Run Code Online (Sandbox Code Playgroud)
将此选项添加到squid.conf 可以修复此问题:
dns_v4_first on
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1573 次 |
| 最近记录: |