I am trying to expose a (Dockerize) Nexus 3 NPM registry behind Apache HTTPD on CentOS.
I have this virualhost:
<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>
I also added the above two lines at the end of /etc/httpd/conf/httpd.conf
# Allow Encoded Slashes for Nexus NPM
AllowEncodedSlashes On
AllowEncodedSlashes NoDecode
However when I try to push a npm package with a @scope and hence a slash in the name, I always get a 404 error.
I tried to publish the same npm package but without the slash and it is working. Therefore I am sure the problem is with apache, also considering the other questions and websites I found about the problem.
This is the error I get:
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
and the details of the 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
Related questions/links
- 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