nexus部署及配置https访问

1. 使用docker-compose部署nexus

  1. docker-compose-nexus.yml

    yaml 复制代码
    version: "3"
    services:
      nexus:
        container_name: my-nexus
        image: sonatype/nexus3:3.67.1
        hostname: my-nexus
        network_mode: host
        ports:
          - 8081:8081
        deploy:
          resources:
            limits:
              cpus: '4'
              memory: 8192M
            reservations:
              cpus: '4'
              memory: 4096M
        healthcheck:
          test: ["CMD", "curl", "-f", "http://localhost:8081"]
          interval: 30s
          timeout: 10s
          retries: 3
        volumes:
          - "/data/nexus:/nexus-data"
          - "/etc/localtime:/etc/localtime"
        restart: always
        
  2. 部署

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

    shell 复制代码
    vim /etc/hosts
    
    192.168.xxx.xxx my-nexus
  4. 防火墙开放8081端口

    shell 复制代码
    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

    yaml 复制代码
    version: "3"
    services:
      nginx:
         restart: always
         image: nginx:1.26.2
         container_name: my-nginx
         hostname: my-nginx
         network_mode: host
         privileged: true
         volumes:
           - "/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证书,放到指定目录

    • 配置文件

      conf 复制代码
      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. 部署

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

    shell 复制代码
    vim /etc/hosts
    
    192.168.xxx.xxx my-nginx
  5. 防火墙开放18081端口

    shell 复制代码
    firewall-cmd --zone=public --add-port=18081/tcp --permanent
    firewall-cmd --reload
  6. web访问

    https://192.168.xxx.xxx:18081

相关推荐
小袁搬码12 分钟前
银河麒麟V10SP3Server中离线安装Docker引擎与docker-compose
linux·docker·容器·kylin·银河麒麟v10·离线安装docker
qq75903536614 分钟前
2025 linux系统资源使用率统计docker容器使用率统计docker监控软件Weave Scope安装weavescope
linux·运维·docker
Dontla22 分钟前
Axios介绍(前端开发处理网络请求首选工具,基于Promise HTTP客户端,可以在浏览器和Node.js环境使用)(Axios库)
网络·http·node.js
dmy1 小时前
go最便捷的http请求包resty
后端·http
Bruce Jue3 小时前
计算机网络开发--阻塞与非阻塞、同步与异步、http协议
网络协议·计算机网络·http
企鹅侠客5 小时前
MAC地址IP地址如何转换?
网络协议·tcp/ip·macos
9527出列5 小时前
什么是CGI程序
网络协议
菜菜小蒙5 小时前
【Linux】https 协议
网络协议·http·https
fenglllle6 小时前
K8S下nodelocaldns crash问题导致域名请求响应缓慢
docker·容器·kubernetes
小白学安全hhhh7 小时前
VPC4-通达oa-docker逃逸-shiro反序列化-hash传递-CrackMapExec喷射-历史ptt攻击-进程注入
运维·安全·网络安全·docker·容器·网络攻击模型·安全架构