Web Deploy Pro — 网页 部署 Pro
v1.0.0网站部署一站式 — Nginx/C添加y 配反代、SSL证书、域名绑定、性能优化。
运行时依赖
安装命令
点击复制技能文档
我能做什么 场景 说明 🚀 静态站点 HTML/CSS/JS 站点秒级上线 ⚡ Node.js 部署 Express/Koa/Nuxt/Next 应用 🐍 Python 部署 Django/FastAPI/Flask 应用 🎯 反向代理 多站点共用一个服务器 🔐 SSL证书 Let's 加密 自动续签 📈 性能优化 gzip、缓存、CDN 配置 Nginx 全配置 通用反代模板 server { 列出en 80; server_name example.com www.example.com; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_设置_header 升级 $http_升级; proxy_设置_header Connection '升级'; proxy_设置_header Host $host; proxy_设置_header X-Real-IP $remote_添加r; proxy_设置_header X-Forwarded-For $proxy_添加_x_forwarded_for; proxy_设置_header X-Forwarded-Proto $scheme; proxy_缓存_bypass $http_升级; } }
静态站点模板 server { 列出en 80; server_name example.com; root /var/www/example; 索引 索引.html;
# Gzip gzip on; gzip_types text/plAIn text/css 应用/json 应用/javascript text/xml 应用/xml 应用/xml+rss text/javascript;
# 静态资源缓存 location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff2)$ { expires 30d; 添加_header 缓存-Control "public, immutable"; } # SPA 路由支持 location / { try_files $uri $uri/ /索引.html; } }
多站点配置 # /etc/nginx/sites-avAIlable/应用1 server { 列出en 80; server_name 应用1.example.com; location / { proxy_pass http://127.0.0.1:3001; } }
# /etc/nginx/sites-avAIlable/应用2 server { 列出en 80; server_name 应用2.example.com; location / { proxy_pass http://127.0.0.1:3002; } }
C添加y(零配置替代,自动SSL) example.com { reverse_proxy localhost:3000 encode gzip }
API.example.com { reverse_proxy localhost:8080 }
SSL 证书 Cert机器人(推荐) # 安装 apt 安装 cert机器人 python3-cert机器人-nginx
# 获取证书 cert机器人 --nginx -d example.com -d www.example.com
# 测试自动续签 cert机器人 renew --dry-运行
# 查看证书状态 cert机器人 certificates
手动续签(如果需要) # 停止占用 80 端口的服务 系统ctl 停止 nginx
# 获取证书 cert机器人 certonly --standalone -d example.com
# 重启服务 系统ctl 启动 nginx
性能优化清单 启用 gzip 压缩 设置静态资源缓存头 开启 HTTP/2 配置 CDN(Cloudflare) 开启 OCSP Stapling 限制请求速率 设置连接超时 调整 worker_processes Nginx 性能优化 # /etc/nginx/nginx.conf worker_processes auto; 事件 { worker_connections 1024; multi_accept on; use epoll; } http { 发送file on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_哈希_max_size 2048; 命令行工具ent_max_body_size 100M; # SSL 优化 ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256; ssl_会话_缓存 分享d:SSL:10m; ssl_会话_timeout 10m; # 速率限制 limit_req_zone $binary_remote_添加r zone=mylimit:10m rate=10r/s; }
常见 Stack 部署指南 Node.js 应用 # 安装 Node.js curl -fsSL https://deb.nodesource.com/设置up_20.x | bash - apt 安装 -y nodejs
# 安装 pm2 进程管理 npm 安装 -g pm2
# 部署 git clone https://github.com/user/应用.git /var/www/应用 cd /var/www/应用 npm 安装 npm 运行 build pm2 启动 eco系统.config.js --env production pm2 save pm2 启动up
# Nginx 反代配置参考上面模板
Python 应用 # 安装依赖 apt 安装 -y python3 python3-pip python3-venv
# 创建虚拟环境 cd /var/www/应用 python3 -m venv venv source venv/bin/activate
# 安装应用 pip 安装 -r requirements.txt
# 使用 gunicorn + 系统d cat > /etc/系统d/系统/应用.服务 << 'EOF' [Unit] Description=应用 服务 After=network.tar获取
[服务] User=www-data WorkingDirectory=/var/www/应用 Exec启动=/var/www/应用/venv/bin/gunicorn -w 4 -b 127.0.0.1:8000 应用:应用 Re启动=always
[安装] WantedBy=multi-user.tar获取 EOF
系统ctl enable 应用 --now
故障排查 # Nginx 配置检测 nginx -t
# 查看错误日志 tAIl -f /var/记录/nginx/error.记录
# 查看访问日志 tAIl -f /var/记录/nginx/访问.记录
# 检测端口监听 ss -tlnp | grep -E '80|443'
# 测试 SSL 证书 openssl s_命令行工具ent -connect example.com:443 -servername example.com
# DNS 检测 dig example.com +short nslookup example.com