注意:
1,不要使用docker版的nexus,要不然哭的很惨
2,SSL的key怎么弄这里就不做说明了
3,nginx,nexus安装网上太多了哈就不说了
整活儿
- 配置nginx
截取部分配置信息
server {
listen 443 ssl;
server_name localhost;
root /usr/share/nginx/html;
underscores_in_headers on;
ssl_certificate "/etc/nginx/key/XXXXX.pem";
ssl_certificate_key "/etc/nginx/key/XXXXX.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8085;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
没有什么特殊的 underscores_in_headers 表示头信息可以用下划线
重启 ./nginx -s reload
- 配置nexus
- 再nexus中添加证书(读取PEM,复制进去)
配置匿名访问
- 配置库,maven和vue大体一样,就是在创建host,group,proxy的时候别选错了,这里就拿vue举例
先创建blob
创建host
创建proxy(可能有多个)
可以根据自己的服务器网速用nrm 或者yrm测试一下
这里是常用的代理地址
npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ tencent npm mirrors
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
创建group,把刚刚创建的htos和proxy都放进去
重启nexus
- 在客户端使用的时候需要登陆
npm login --registry='https://ip:8081/repository/npm-public/'
更换源
npm config set registry 'https://ip:8081/repository/npm-public/'
npm install
- Maven的配置
在打包的过程中可能会遇到的错
(1) sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
(2) Could not transfer artifact org.jyaml:jyaml:pom:1.3 from/to nexus (https://ip/repository/info-public/): Transfer failed for phttps://ip/repository/info-public/org/jyaml/jyaml/1.3/jyaml-1.3.pom
都是一个解决方法(注意配置好环境变量)
mvn clean install -Dmaven.test.skip=true -Dmaven.multiModuleProjectDirectory=$MAVEN_HOME -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
(3) npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
解决 客户端需要登陆
(4) npm ERR! Failed at the nodent-runtime@3.2.1 install script.
npm ERR! Failed at the node-sass@4.14.1 postinstall script.
这个需要先设置
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
(5) Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.
https访问时不能直接用ip需要映射一个域名
在设置一下ssl忽略验证 yarn & npm config set strict-ssl false
(6) 每个用户有自己的yarn配置,查看 yarn config list
删除配置 npm config delete <#name#>