使用 Docker 部署 nexus3

本文分享如何使用 Docker 部署 nexus3

如果您是第一次阅读该系列文章,建议优先阅读 Docker 部署项目说明及索引

Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
version: "3.9"

services:
  nexus3:
    image: sonatype/nexus3:latest
    container_name: nexus3
    hostname: nexus3
    restart: unless-stopped
    ports:
      - "8081:8081"
    volumes:
      - /docker/nexus/nexus-data:/nexus-data
    environment:
      - TZ=Asia/Shanghai
networks:
  default:
    external: true
    name: rod

使用 nexus3

打开链接: (http://localhost:8081 ):

NPM 反向代理配置

此处以 https://nexus3.example.com 为例

如果未部署 NPM,可参考文章:使用 Docker 部署 Nginx Proxy Manager

Details

  • Domain Names: nexus3.example.com
  • Scheme: http
  • Forward Hostname/IP: 127.0.0.1 (如果 NPM 未使用 HOST,则使用容器的 hostname: nexus3)
  • Forward Port: 8081
  • Cache Assets: ✅

SSL

  • 选择你已经配置好的 SSL Certificate,如 *.example.com, example.com
  • Force SSL: ✅
  • HTTP/2 Support: ✅

Advanced

1
2
3
4
5
6
7
8
location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_pass $forward_scheme://$server:$port;
}

如果本文对您有所帮助,欢迎打赏支持作者!

Licensed under CC BY-NC-SA 4.0
最后更新于 2026-08-06 10:00
使用 Hugo 构建
主题 StackJimmy 设计