Skip to content

ECS 生产部署

这页给你一个可直接改造的上线思路:

  • 主站:yolo.chengxiaoyu.top
  • 文档站:docs.yolo.chengxiaoyu.top

1. 构建前端与文档静态资源

bash
# 前端
cd frontend
npm ci
npm run build

# 文档
cd ../docs
npm ci
npm run docs:build

2. Nginx 反向代理(示例)

nginx
server {
    listen 80;
    server_name yolo.chengxiaoyu.top;

    location / {
        root /var/www/yolo-frontend;
        index index.html;
        try_files $uri $uri/ /index.html;
    }

    location /api/ {
        proxy_pass http://127.0.0.1:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /flask/ {
        proxy_pass http://127.0.0.1:8080/flask/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen 80;
    server_name docs.yolo.chengxiaoyu.top;

    location / {
        root /var/www/yolo-docs;
        index index.html;
        try_files $uri $uri/ /index.html;
    }
}

3. HTTPS

建议使用 Certbot 申请证书:

bash
sudo certbot --nginx -d yolo.chengxiaoyu.top -d docs.yolo.chengxiaoyu.top

4. 上线检查清单

  • 域名解析是否生效
  • 80/443 端口是否放行
  • 后端 8080、ML 5000 是否本机可访问
  • 前端是否能正常请求 /api/flask
  • 文档站链接是否可访问