目 录CONTENT

文章目录

🚀 在 Scaleway Serverless Containers 上部署 ServerStatus (Rust)

Leu
Leu
2025-10-27 / 0 评论 / 1 点赞 / 8 阅读 / 0 字

本教学将一步步说明如何打包、部署与绑定自订网域,并确保 HTTPS 与免费额度运作良好。

一、环境准备

需求条件

sudo apt install docker.io -y

二、建立专案目录与设定档

mkdir stat_server
cd stat_server

建立设定档 config.toml

请前往官网下载并修改

三、撰写 Dockerfile

在专案根目录新增 Dockerfile

FROM idoge/stat_server:latest
COPY config.toml /config.toml
EXPOSE 8080
CMD ["./stat_server"]

这份映像会使用 Rust ServerStatus 主程式,并带入自订设定。

四、打包与上传映像

登入 Docker Hub:

docker login

建构与推送映像:

docker build -t <DockerHub帐号>/stat_server:latest .
docker push <DockerHub帐号>/stat_server:latest

推送完成后,可在 Docker Hub 介面确认。

五、部署至 Scaleway Serverless Containers

1. 建立 Namespace

2. 建立容器

使用可免费运作的记忆体/CPU 设定:

scw container container create \
  name=stat-server \
  namespace-id=<namespace-id> \
  registry-image=<DockerHub帐号>/stat_server:latest \
  memory-limit=150 \
  cpu-limit=72 \
  port=8080 \
  min-scale=1 \
  max-scale=1 \
  deploy=true \
  region=fr-par

说明:

  • memory-limit=150 MB、cpu-limit=72 mvCPU → 符合免费额度。

  • min-scale=1 避免冷启动。

  • max-scale=1 固定单节点运作。

完成后你会得到 Scaleway 系统自动产生的 HTTPS 网址,例如:

https://xxxxxx-stat-server.functions.fnc.fr-par.scw.cloud

六、绑定自订网域(可选)

若想用自己的短域名(例如 stat.example.com):

1. 在 DNS 建立 CNAME

stat.example.com  CNAME  xxxxxx-stat-server.functions.fnc.fr-par.scw.cloud

2. 在 Scaleway Console → 容器页 → Endpoints 分页:

  • +Add endpoint

  • 输入自订网域,例如 stat.example.com

Scaleway 会自动:

  1. 验证 CNAME 配置;

  2. 使用 Let’s Encrypt 签凭证;

  3. 启用 HTTPS。

⚠️ 验证期间(pending 状态)约 3 分钟,请确保 DNS 已生效(可用 dig 测试)。

七、免费额度提示

Scaleway 每月免费:

  • 400 000 GB‑s 记忆体运行

  • 200 000 vCPU‑s 处理运算

前述 memory-limit=150cpu-limit=72 组合能在免费范围内全天持续运行。

🔧 常见问题

问题

原因

解法

首次访问延迟

容器冷启动

设定 min-scale=1

HTTPS 显示不安全

仅做 CNAME,未在 Scaleway 新增 Endpoint

重新 Add endpoint

Cloudflare 验证失败

验证时 Proxy 开启

关闭小黄云再验证

无法通过 ACME

DNS未生效

等 TTL 过期后重试

✅ 部署完成!

至此,你已成功将 ServerStatus Rust 伺服器 部署至 Scaleway Serverless Containers
支援 HTTPS 自动凭证,并维持在免费额度内长期稳定运作。

为了防止丢资料流量请使用vnstat计算

客户端快速部署 更改域名跟gid 密码为config内容

curl -sSLf "https://aaa.com/i?pass=1344&gid=gg&alias=alias&vnstat=1" | sudo bash

1
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区