MultiWebLLMv0.0.1

部署指南

生产环境部署 MultiWebLLM

Docker Compose 部署

基本部署

git clone https://github.com/gentpan/multiwebllm.git
cd multiwebllm
cp .env.example .env
# 编辑 .env 配置
docker compose up -d

查看日志

docker compose logs -f

更新版本

docker compose pull
docker compose up -d

Nginx 反向代理

推荐使用 Nginx 反向代理,配置 HTTPS 和域名访问。

Nginx 配置

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
        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;
    }

    # SSE 流式输出支持
    location /v1/chat/completions {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection '';
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
    }
}

SSL 证书

使用 Certbot 申请免费证书

# 安装 certbot
apt install certbot python3-certbot-nginx

# 申请证书
certbot --nginx -d your-domain.com

# 自动续期
certbot renew --dry-run

服务器建议

最低配置

  • CPU: 1 核
  • 内存: 2GB+
  • 硬盘: 10GB+
  • 系统: Ubuntu 22.04 / Debian 12

添加 Swap(推荐)

如果内存较小,建议添加 swap:

# 创建 2GB swap
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

# 持久化
echo '/swapfile none swap sw 0 0' >> /etc/fstab

防火墙配置

# 允许 HTTP/HTTPS
ufw allow 80
ufw allow 443

# 不要暴露 3000 端口到公网
# 通过 Nginx 反向代理访问

数据备份

数据库文件默认存储在 ./data/ 目录:

# 备份
cp -r ./data ./data-backup-$(date +%Y%m%d)

# 定时备份(crontab)
0 3 * * * cp -r /path/to/multiwebllm/data /path/to/backup/data-$(date +\%Y\%m\%d)