欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > nexus部署及配置https访问

nexus部署及配置https访问

2025/2/22 16:54:37 来源:https://blog.csdn.net/u013071014/article/details/145498793  浏览:    关键词:nexus部署及配置https访问

1. 使用docker-compose部署nexus

  1. docker-compose-nexus.yml

    version: "3"
    services:nexus:container_name: my-nexusimage: sonatype/nexus3:3.67.1hostname: my-nexusnetwork_mode: hostports:- 8081:8081deploy:resources:limits:cpus: '4'memory: 8192Mreservations:cpus: '4'memory: 4096Mhealthcheck:test: ["CMD", "curl", "-f", "http://localhost:8081"]interval: 30stimeout: 10sretries: 3volumes:- "/data/nexus:/nexus-data"- "/etc/localtime:/etc/localtime"restart: always
  2. 部署

    docker-compose -f docker-compose-nexus.yml up -d
    
  3. 根据自己服务器IP地址,配置hosts

    vim /etc/hosts192.168.xxx.xxx my-nexus
    
  4. 防火墙开放8081端口

    firewall-cmd --zone=public --add-port=8081/tcp --permanent
    firewall-cmd --reload
    
  5. web访问

    http://192.168.xxx.xxx:8081

    用户名:admin

    容器创建会生成默认密码,在容器内的/nexus-data/admin.password中。由于做了数据卷映射。所以在宿主机/data/nexus中也能看到admin.password

    使用默认密码登录成功后,根据提示修改密码

2. 配置https访问

  1. docker-compose-nginx.yml

    version: "3"
    services:nginx:restart: alwaysimage: nginx:1.26.2container_name: my-nginxhostname: my-nginxnetwork_mode: hostprivileged: truevolumes:- "/config/nginx/nginx.conf:/etc/nginx/nginx.conf"- "/config/nginx/conf.d:/etc/nginx/conf.d"- "/logs/nginx:/var/log/nginx"- "/data/nginx:/data/nginx"
    
  2. ssl证书及配置文件

    • 自己生成ssl证书,放到指定目录

    • 配置文件

      server {listen    18081 ssl;server_name  localhost;ssl_certificate      /etc/nginx/conf.d/certs/server.crt;ssl_certificate_key  /etc/nginx/conf.d/certs/server.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;ssl_protocols TLSv1.2 TLSv1.3;ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;ssl_prefer_server_ciphers  on;server_tokens off;add_header Strict-Transport-Security "max-age=3600; includeSubDomains";client_max_body_size 2000m;root html;charset 'utf-8';location / {proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header    Host $http_host;proxy_set_header   X-Forwarded-Proto https;  # 转发时使用https协议server_name_in_redirect on;proxy_pass      http://my-nexus:8081;}}
      
  3. 部署

    docker-compose -f docker-compose-nginx.yml up -d
    
  4. 根据服务器IP,配置hosts

    vim /etc/hosts192.168.xxx.xxx my-nginx
    
  5. 防火墙开放18081端口

    firewall-cmd --zone=public --add-port=18081/tcp --permanent
    firewall-cmd --reload
    
  6. web访问

    https://192.168.xxx.xxx:18081

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词