喵pass

使用 Docker Compose 部署 Nginx Proxy Manager

2025/10/30
6
0

完整设置说明

官方地址:Nginx Proxy Manager

注意:设置中文需要将 image: 'jc21/nginx-proxy-manager:latest'替换成image: 'chishin/nginx-proxy-manager-zh:latest'

创建一个文件:docker-compose.yml

YML

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP

    #environment:
      # Uncomment this if you want to change the location of
      # the SQLite DB file within the container
      # DB_SQLITE_FILE: "/data/database.sqlite"

      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

然后:

抨击

docker compose up -d

使用 MySQL / MariaDB 数据库

如果您选择 MySQL 配置,则必须自己提供数据库服务器。您也可以使用 MariaDB。以下是支持的最低版本:

  • MySQL v5.7.8+

  • MariaDB v10.2.7+

为您的数据库使用另一个 docker 容器并将其链接为 docker 堆栈的一部分也很容易,因此这就是以下示例将使用的。

以下是使用 MariaDB 容器时的外观示例:docker-compose.yml

YML

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      # Mysql/Maria connection parameters:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
      MARIADB_AUTO_UPGRADE: '1'
    volumes:
      - ./mysql:/var/lib/mysql

警告

请注意,环境变量将优先于变量。因此,如果您保留 MySQL 变量,您将无法使用 SQLite。DB_MYSQL_*DB_SQLITE_*

使用 Postgres 数据库

与 MySQL 服务器设置类似:

YML

services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      # Postgres parameters:
      DB_POSTGRES_HOST: 'db'
      DB_POSTGRES_PORT: '5432'
      DB_POSTGRES_USER: 'npm'
      DB_POSTGRES_PASSWORD: 'npmpass'
      DB_POSTGRES_NAME: 'npm'
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: postgres:latest
    environment:
      POSTGRES_USER: 'npm'
      POSTGRES_PASSWORD: 'npmpass'
      POSTGRES_DB: 'npm'
    volumes:
      - ./postgres:/var/lib/postgresql/data

警告

不支持自定义 Postgres 架构,因为将使用此类架构。public

在 Raspberry PI / ARM 设备上运行

docker 镜像支持以下体系结构:

  • AMD64的

  • 手臂64

  • ARMv7

docker 镜像是支持的所有架构 docker 构建的清单,因此这意味着您不必担心做任何特殊的事情,您可以按照上面的常见说明进行作。

查看 dockerhub 标签以获取受支持的架构列表,如果您想要一个不存在的架构,请创建一个功能请求

此外,如果您还不知道如何作,请按照本指南在 Raspbian 上安装 docker 和 docker-compose

请注意,该映像在某些 ARM 设备上可能会出现一些问题,如果您想要一个单独的数据库容器,请使用该映像。jc21/mariadb-aria:latestyobasystems/alpine-mariadb:latest

初始运行

应用首次运行后,将发生以下情况:

  1. JWT 密钥将生成并保存在数据文件夹中

  2. 数据库将使用表结构进行初始化

  3. 将创建一个默认管理员用户

此过程可能需要几分钟,具体取决于您的机器。

默认管理员用户

Email:    admin@example.com
Password: changeme

使用此默认用户登录后,系统会立即要求您修改您的详细信息并更改密码。您可以使用以下命令更改默认值:

    environment:
      INITIAL_ADMIN_EMAIL: my@example.com
      INITIAL_ADMIN_PASSWORD: mypassword1

赞赏码.png