dstatus + Cloudflare 完整部署步骤

举报
yd_229065422 发表于 2026/10/31 18:17:42 2026/10/31
【摘要】 一、部署 dstatuscurl -fsSL https://down.vps.mom/downloads/docker-image/install.sh | bash -s -- --image-tag=stable --port=5555 --install-dir=/opt/dstatus 二、生成自签 SSL 证书openssl req -x509 -nodes -days 365...

一、部署 dstatus

curl -fsSL https://down.vps.mom/downloads/docker-image/install.sh | bash -s -- --image-tag=stable --port=5555 --install-dir=/opt/dstatus

二、生成自签 SSL 证书

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
  -keyout /etc/ssl/private/dstatus.key \
  -out /etc/ssl/certs/dstatus.crt \
  -subj "/CN=你的域名"

三、配置 Nginx 反代

apt install nginx -y
nano /etc/nginx/sites-available/dstatus

写入以下内容(替换域名):

server {
    listen 80;
    server_name 你的域名;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name 你的域名;

    ssl_certificate     /etc/ssl/certs/dstatus.crt;
    ssl_certificate_key /etc/ssl/private/dstatus.key;

    location / {
        proxy_pass         http://127.0.0.1:5555;
        proxy_set_header   Host $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_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
        proxy_read_timeout 86400;
    }
}
ln -s /etc/nginx/sites-available/dstatus /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

四、放行防火墙端口

OCI 控制台安全列表(入站规则添加)

源 CIDR 协议 目标端口 无状态
0.0.0.0/0 TCP 80 禁用
0.0.0.0/0 TCP 443 禁用

系统 iptables(OCI 必须做这步)

# 在 REJECT 规则之前插入
iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 443 -j ACCEPT
# 在 REJECT 本机探针agent
iptables -I INPUT 5 -p tcp --dport 9999 -j ACCEPT

# 持久化保存
apt install iptables-persistent -y
netfilter-persistent save

⚠️ OCI 有兜底 REJECT all 规则,必须用 -I INPUT 插在它之前,否则端口仍然被拦。


五、Cloudflare 配置

DNS 记录:

类型 名称 内容 代理状态
A 子域名 服务器IP 🟠 已代理

SSL/TLS → 概述:

  • 加密模式选「完全」(不要选「完全严格」,自签证书不支持)

最终链路

浏览器 → CF 小黄云(HTTPS)→ Nginx 443 → dstatus 5555

dstatus 内置支持切换 PostgreSQL!按下面步骤操作:


第一步:在 docker-compose.yml 里加入 PostgreSQL 容器

nano /opt/dstatus/docker-compose.yml

在 services: 下面加入 postgres 服务,完整文件改成这样:

services:
  dstatus:
    image: ghcr.io/fev125/dzstatus:stable
    container_name: dstatus
    ports:
      - "127.0.0.1:5555:5555"
    volumes:
      - /opt/dstatus/data:/app/data
      - /opt/dstatus/logs:/app/logs
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - TZ=Asia/Shanghai
      - NODE_ENV=production
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - dstatus_network

  postgres:
    image: postgres:16-alpine
    container_name: dstatus-postgres
    environment:
      - POSTGRES_DB=dstatus
      - POSTGRES_USER=dstatus
      - POSTGRES_PASSWORD=你的强密码
    volumes:
      - /opt/dstatus/pgdata:/var/lib/postgresql/data
    restart: unless-stopped
    networks:
      - dstatus_network

networks:
  dstatus_network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: "172.30.0.0/16"

第二步:启动 PostgreSQL

cd /opt/dstatus
docker compose up -d postgres

# 等几秒确认 postgres 正常运行
docker ps | grep postgres

第三步:在面板填写配置

回到面板「数据库」页面,填写:

字段 值
主机地址 postgres(容器名,不是 localhost)
端口 5432
数据库名 dstatus
用户名 dstatus
密码 你在 compose 里设置的密码

填完先点「测试连接」,显示成功后再点「保存配置」→「切换到 PostgreSQL」。


⚠️ 主机地址填 postgres(容器名)而不是 localhost,因为两个容器在同一个 Docker 网络里通过容器名互相访问。

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0)

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。