【发布时间】:2022-01-23 07:44:51
【问题描述】:
我正在尝试在 CentOS 上的 Apache HTTPD 后面公开一个(Dockerize)Nexus 3 NPM 注册表。
我有这个虚拟主机:
<VirtualHost *:80>
ServerName ci-cd.domain
DocumentRoot /var/www/cicd
ProxyRequests Off
ProxyPreserveHost on
# Allow Encoded Slashes for Nexus NPM
AllowEncodedSlashes On
AllowEncodedSlashes NoDecode
#
#Nexus
#
Redirect /nexus /nexus/
ProxyPass /nexus/ http://localhost:10000/nexus/ nocanon
ProxyPassReverse /nexus/ http://localhost:10000/nexus/
</VirtualHost>
我还在/etc/httpd/conf/httpd.conf末尾添加了上面两行
# Allow Encoded Slashes for Nexus NPM
AllowEncodedSlashes On
AllowEncodedSlashes NoDecode
但是,当我尝试使用 @scope 推送 npm 包时,因此名称中有斜线, 我总是收到 404 错误。
我尝试发布相同的 npm 包,但没有斜杠,它正在工作。 因此,我确定问题出在 apache 上,同时考虑到我发现的有关该问题的其他问题和网站。
这是我得到的错误:
npm notice
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://ci-ci.domain/nexus/repository/my-npm/@myscope%2fmylib
npm ERR! 404
npm ERR! 404 '@myscope/mylib@1.0.0' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2021-12-21T23_46_48_369Z-debug.log
以及日志的详细信息:
35 timing command:publish Completed in 2695ms
36 verbose stack HttpErrorGeneral: 404 Not Found - PUT https://cicd.domain/nexus/repository/my-npm/@myscope%2fmylib
36 verbose stack at /home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:95:15
36 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5)
36 verbose stack at async publish (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/libnpmpublish/publish.js:43:12)
36 verbose stack at async Publish.exec (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/lib/commands/publish.js:121:7)
36 verbose stack at async module.exports (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/lib/cli.js:67:5)
37 verbose statusCode 404
38 verbose pkgid @myscope/mylib@1.0.0
39 verbose cwd 35 timing command:publish Completed in 2695ms
36 verbose stack HttpErrorGeneral: 404 Not Found - PUT https://cicd.domain/nexus/repository/my-npm/@myscope%2fmylib
36 verbose stack at /home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:95:15
36 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5)
36 verbose stack at async publish (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/libnpmpublish/publish.js:43:12)
36 verbose stack at async Publish.exec (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/lib/commands/publish.js:121:7)
36 verbose stack at async module.exports (/home/izio/.nvm/versions/node/v14.17.0/lib/node_modules/npm/lib/cli.js:67:5)
37 verbose statusCode 404
38 verbose pkgid @myscope/mylib@1.0.0
39 verbose cwd /mnt/bytes/Workspace/project/mylib
40 verbose Linux 5.15.7-051507-generic
41 verbose argv "/home/izio/.nvm/versions/node/v14.17.0/bin/node" "/home/izio/.nvm/versions/node/v14.17.0/bin/npm" "publish" "dist/"
42 verbose node v14.17.0
43 verbose npm v8.1.3
44 error code E404
45 error 404 Not Found - PUT https://cicd.domain/nexus/repository/my-npm/@myscope%2fmylib
46 error 404
47 error 404 '@myscope/mylib@1.0.0' is not in this registry.
48 error 404 You should bug the author to publish it (or use the name yourself!)
49 error 404 Note that you can also install from a
50 error 404 tarball, folder, http url, or git url.
51 verbose exit 1
40 verbose Linux 5.15.7-051507-generic
41 verbose argv "/home/izio/.nvm/versions/node/v14.17.0/bin/node" "/home/izio/.nvm/versions/node/v14.17.0/bin/npm" "publish" "dist/"
42 verbose node v14.17.0
43 verbose npm v8.1.3
44 error code E404
45 error 404 Not Found - PUT https://cicd.domain/nexus/repository/my-npm/@myscope%2fmylib
46 error 404
47 error 404 '@myscope/mylib@1.0.0' is not in this registry.
48 error 404 You should bug the author to publish it (or use the name yourself!)
49 error 404 Note that you can also install from a
50 error 404 tarball, folder, http url, or git url.
51 verbose exit 1
相关问题/链接
- Need to allow encoded slashes on Apache
- https://blog.sandra-parsick.de/2018/04/29/apache2-as-reverse-proxy-for-npm-registry-proxies-in-sonatype-nexus-3/
- https://serverfault.com/questions/455060/cant-get-mod-proxy-to-correctly-forward-encoded-slash-characters-2f
- https://issues.sonatype.org/plugins/servlet/mobile#issue/NEXUS-10570
- https://httpd.apache.org/docs/2.4/mod/core.html#allowencodedslashes
【问题讨论】: