repo 测试

安装 cnpm

# npm install -g cnpm --registry=http://192.168.80.129:8081/repository/npm-aliyun-repo/
added 1 package in 20s 59 packages are looking for funding run `npm fund` for details

查看 cnpm 版本信息

# cnpm version
cnpm@9.4.0 (/usr/local/node-v20.11.1-linux-x64/lib/node_modules/cnpm/lib/parse_argv.js)
npm@9.9.2 (/usr/local/node-v20.11.1-linux-x64/lib/node_modules/cnpm/node_modules/npm/index.js)
node@20.11.1 (/usr/local/node-v20.11.1-linux-x64/bin/node)
npminstall@7.12.0 (/usr/local/node-v20.11.1-linux-x64/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)
prefix=/usr/local/node-v20.11.1-linux-x64 
linux x64 6.5.0-14-generic 
registry=https://registry.npmmirror.com

查看

nexus(192.168.80.128:8081) --> nginx(192.168.80.129:19000,192.168.80.129:80) --> http://mirrors.huaweicloud.com/

nginx 配置

server {
    listen       19000;
    server_name  localhost;
    # 设置代理访问日志
    access_log /var/log/nginx/npm.access.log ;
    error_log  /var/log/nginx/npm.error.log ;
    location /npm-huawei/ {
	    proxy_pass http://mirrors.huaweicloud.com/;
        proxy_set_header X-Forwarded-Host npm-huaweicloud-repo;
        proxy_set_header Host npm-huaweicloud-repo;
server {
    listen       80;
    server_name  npm-huaweicloud-repo;
    location / {
	    proxy_pass http://mirrors.huaweicloud.com;

nexus 配置

services:
  nexus3:
    image: sonatype/nexus3:3.68.1
    container_name: nexus3
    restart: always
    extra_hosts:
      - "npm-huaweicloud-repo:192.168.80.129"
    environment:
      - TZ=Asia/Shanghai
    networks:
      nexus-bridge:
    ports:
      - 8081:8081
    volumes:
      - ./nexus-data:/nexus-data
      - /etc/localtime:/etc/localtime
networks:
  nexus-bridge:
    driver: bridge

repository

npm 配置

# npm config set registry http://192.168.80.128:8081/repository/npm-huawei/
# npm cache clean -f

安装包测试

# npm --loglevel info install cnpm
npm info using npm@10.8.0
npm info using node@v20.13.1
npm http fetch GET 200 http://192.168.80.128:8081/repository/npm-huawei/cnpm 171ms (cache miss)
npm http fetch GET 200 http://192.168.80.128:8081/repository/npm-huawei/cnpm/-/cnpm-9.4.0.tgz 10063ms (cache miss)
npm http fetch POST 401 http://192.168.80.128:8081/repository/npm-huawei/-/npm/v1/security/advisories/bulk 81ms
npm http fetch POST 400 http://192.168.80.128:8081/repository/npm-huawei/-/npm/v1/security/audits/quick 14ms
added 1 package in 12s
55 packages are looking for funding
  run `npm fund` for details
npm info ok

查看请求信息

修改日志为 TRACE

2024-05-23 10:57:37,260+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: ignoreCookies
2024-05-23 10:57:37,261+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
2024-05-23 10:57:37,261+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://192.168.80.129:19000
2024-05-23 10:57:37,262+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to /192.168.80.129:19000
2024-05-23 10:57:37,264+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 172.19.0.2:51266<->192.168.80.129:19000
2024-05-23 10:57:37,264+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-42: set socket timeout to 20000
2024-05-23 10:57:37,265+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Executing request GET /npm-huawei/repository/npm/cnpm HTTP/1.1
2024-05-23 10:57:37,266+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
2024-05-23 10:57:37,267+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
2024-05-23 10:57:37,268+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 >> GET /npm-huawei/repository/npm/cnpm HTTP/1.1
2024-05-23 10:57:37,268+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 >> Host: 192.168.80.129:19000
2024-05-23 10:57:37,269+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 >> Connection: Keep-Alive
2024-05-23 10:57:37,270+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 >> User-Agent: Nexus/3.68.1-02 (OSS; Linux; 6.8.0-31-generic; amd64; 1.8.0_412)
2024-05-23 10:57:37,270+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 >> Accept-Encoding: gzip,deflate
2024-05-23 10:57:37,322+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << HTTP/1.1 200 
2024-05-23 10:57:37,323+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Server: nginx/1.26.0
2024-05-23 10:57:37,323+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Date: Thu, 23 May 2024 02:57:37 GMT
2024-05-23 10:57:37,323+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Content-Type: application/json;charset=UTF-8
2024-05-23 10:57:37,324+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Transfer-Encoding: chunked
2024-05-23 10:57:37,324+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Connection: keep-alive
2024-05-23 10:57:37,324+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Set-Cookie: HWWAFSESID=4e9c01d877f3742017c; path=/
2024-05-23 10:57:37,324+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Set-Cookie: HWWAFSESTIME=1716433052424; path=/
2024-05-23 10:57:37,325+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << lubanops-gtrace-id: v-648609-1716433057316-31065047
2024-05-23 10:57:37,325+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << lubanops-nenv-id: 269996
2024-05-23 10:57:37,325+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Vary: Origin
2024-05-23 10:57:37,325+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Vary: Access-Control-Request-Method
2024-05-23 10:57:37,326+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Vary: Access-Control-Request-Headers
2024-05-23 10:57:37,326+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Accept-Ranges: bytes
2024-05-23 10:57:37,326+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << X-Checksum-Md5: 1e8c11921bdcd2d8c4cfc4025686f11f
2024-05-23 10:57:37,327+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << X-Checksum-Sha1: b987478383d1324ab4877deadc93b7b556ccf6aa
2024-05-23 10:57:37,327+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << X-Checksum-Sha256: 76a8556306b0a8d4d12b75b41c93783aad6f33539e844d8dc145f848697965fa
2024-05-23 10:57:37,327+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << X-Checksum-Sha512: d674cacdcac9600d512e8a74968f015d0383f60e9ca01e2a566794583710c513238df03ac651f2ae6737b50fd1b4a6c03e3a1ff1a97bc33e3c2a0dee009916c8
2024-05-23 10:57:37,328+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.headers - http-outgoing-42 << Content-Disposition: attachment; filename="package.json"; filename*=UTF-8''%70%61%63%6B%61%67%65%2E%6A%73%6F%6E
2024-05-23 10:57:37,328+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 30000 MILLISECONDS
2024-05-23 10:57:37,365+0800 DEBUG [qtp494527407-558] *UNKNOWN org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-42: set socket timeout to 0
2024-05-23 10:57:37,442+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: ignoreCookies
2024-05-23 10:57:37,443+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
2024-05-23 10:57:37,443+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://npm-huaweicloud-repo:80
2024-05-23 10:57:37,444+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to npm-huaweicloud-repo/192.168.80.129:80
2024-05-23 10:57:37,445+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 172.19.0.2:48586<->192.168.80.129:80
2024-05-23 10:57:37,445+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-43: set socket timeout to 20000
2024-05-23 10:57:37,446+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Executing request GET /repository/npm/cnpm/-/cnpm-9.4.0.tgz HTTP/1.1
2024-05-23 10:57:37,446+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
2024-05-23 10:57:37,446+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
2024-05-23 10:57:37,447+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 >> GET /repository/npm/cnpm/-/cnpm-9.4.0.tgz HTTP/1.1
2024-05-23 10:57:37,447+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 >> Host: npm-huaweicloud-repo
2024-05-23 10:57:37,447+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 >> Connection: Keep-Alive
2024-05-23 10:57:37,448+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 >> User-Agent: Nexus/3.68.1-02 (OSS; Linux; 6.8.0-31-generic; amd64; 1.8.0_412)
2024-05-23 10:57:37,448+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 >> Accept-Encoding: gzip,deflate
2024-05-23 10:57:37,488+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << HTTP/1.1 200 
2024-05-23 10:57:37,489+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Server: nginx/1.26.0
2024-05-23 10:57:37,489+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Date: Thu, 23 May 2024 02:57:37 GMT
2024-05-23 10:57:37,490+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Content-Type: application/octet-stream;charset=UTF-8
2024-05-23 10:57:37,490+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Content-Length: 9104956
2024-05-23 10:57:37,490+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Connection: keep-alive
2024-05-23 10:57:37,490+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Set-Cookie: HWWAFSESID=10752763c49e4d982f; path=/
2024-05-23 10:57:37,491+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Set-Cookie: HWWAFSESTIME=1716433057453; path=/
2024-05-23 10:57:37,491+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << lubanops-gtrace-id: v-648609-1716433057485-31065050
2024-05-23 10:57:37,491+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << lubanops-nenv-id: 269996
2024-05-23 10:57:37,492+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Vary: Origin
2024-05-23 10:57:37,492+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Vary: Access-Control-Request-Method
2024-05-23 10:57:37,492+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Vary: Access-Control-Request-Headers
2024-05-23 10:57:37,492+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Accept-Ranges: bytes
2024-05-23 10:57:37,493+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << X-Checksum-Md5: 36c7cca6641f98f52643282143c74f27
2024-05-23 10:57:37,493+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << X-Checksum-Sha1: be7d297247d203b9e84d02ca6953413245b6be7e
2024-05-23 10:57:37,493+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << X-Checksum-Sha256: 71d033b2211827787dff7f29144e1702bbdeabcf77a7fc7d32c8f6d5c1659511
2024-05-23 10:57:37,494+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << X-Checksum-Sha512: a31be8ce0bb212e5e9ff721ed0912d9872adf3e39ac997cd1f8d3f075826b68936fb47474d2d0ab78b949f9ad9f2a218364e54cf31559aed69671127d27a3f89
2024-05-23 10:57:37,494+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Last-Modified: Tue, 12 Mar 2024 14:19:33 GMT
2024-05-23 10:57:37,495+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << ETag: be7d297247d203b9e84d02ca6953413245b6be7e
2024-05-23 10:57:37,495+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.headers - http-outgoing-43 << Content-Disposition: attachment; filename="cnpm-9.4.0.tgz"; filename*=UTF-8''%63%6E%70%6D%2D%39%2E%34%2E%30%2E%74%67%7A
2024-05-23 10:57:37,496+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 30000 MILLISECONDS
2024-05-23 10:57:38,201+0800 DEBUG [qtp494527407-565] *UNKNOWN org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-43: set socket timeout to 0
2024-05-23 10:57:38,446+0800 INFO  [elasticsearch[4FBD7993-D2BC64CE-4043D5F0-3597D10E-6C305027][clusterService#updateTask][T#1]] *SYSTEM org.elasticsearch.cluster.metadata - [4FBD7993-D2BC64CE-4043D5F0-3597D10E-6C305027] [49e14cd1fa0acf53ef5ca2641b45486af3e096ff] update_mapping [component]

https://help.sonatype.com/en/npm-registry.html#/