
【本文由云服务器代理商:云枢国际yunshuguoji撰写;如果您在阅读后觉得这篇分享很有帮助,烦请您多多点赞。】
海外独立站、跨境 API、企业海外官网、SaaS 后台上线时,大量开发者会遇到统一难题:如何快速搭建稳定对公网访问的 Web 服务,同时兼顾网络速度、多层安全防护、长期可维护性与业务扩容能力。 很多新手选用虚拟主机存在性能上限、无法自定义容器环境;自建裸机缺少弹性扩容与官方快照备份;国内云服务器部署海外站点访问延迟高。 本文基于腾讯云国际云服务器(CVM),采用 2026 年主流 Ubuntu22.04 LTS 环境,完整覆盖服务器初始化、双层安全防护、Docker 容器化、Nginx 反向代理、自动续期 HTTPS 证书、故障排查全流程,所有命令可直接复制执行,新手零门槛落地,也可作为技术团队标准化部署模板。

面向海外用户的官网、独立站、API 服务、轻量 SaaS,核心诉求集中在网络、弹性、安全、运维四大维度,对比说明如下:
落地方案 | 海外访问延迟 | 弹性扩容能力 | 自定义环境权限 | 安全防护体系 | 适配企业规模 |
|---|---|---|---|---|---|
海外虚拟主机 | 中等,共享带宽 | 无法自定义扩容容器 | 受限,禁止底层 Docker | 仅基础 WAF,无自主防火墙 | 个人小型展示站,无复杂业务 |
自建海外裸机 | 低 | 无弹性,硬件固定 | 完全自主 | 需自行搭建防火墙、快照 | 大型自研团队,有专职运维 |
腾讯云国际 CVM | 低,全球多地域就近节点 | 一键升降配、弹性带宽、CBS 扩容 | 完整 root 权限,支持 Docker/K8s | 安全组 + UFW 双层防护、自动快照、密钥登录 | 跨境电商、海外 SaaS、企业官网、初创技术团队 |
腾讯云国际覆盖东南亚、欧洲、美洲多地域节点,适合搭建:
· 海外企业官网、品牌展示独立站
· WordPress、Shopify 镜像类 CMS 站点
· 前后端分离海外 API 服务
· Docker 容器化业务、轻量微服务节点
· 海外产品测试环境、中转后台
在腾讯云国际 CVM(Ubuntu 22.04)部署 Docker Nginx 站点,宿主机 Nginx 反向代理容器服务,全站强制 HTTPS,公网可稳定访问,分层隔离保障安全,后续支持多站点、多容器无缝扩展。 前置条件:域名已完成 A 记录解析至 CVM 公网 IP。
云平台:腾讯云国际 实例产品:CVM 云服务器 操作系统:Ubuntu Server 22.04 LTS 容器:Docker Engine + Docker Compose Plugin 反向代理:宿主机原生 Nginx SSL 证书:Certbot Let’s Encrypt 免费证书
轻量官网、后台、API 测试:1 核 2G 基础实例; 高并发独立站、多用户 SaaS:2 核 4G 及以上规格,支持后期一键升降配,搭配 CBS 弹性磁盘扩容存储。
优先 Ubuntu 22.04 LTS:社区文档完善、Docker/Certbot 兼容稳定、5 年长期安全补丁支持,适合生产环境。
仅开放入站 TCP 端口: 22 SSH 远程登录、80 HTTP、443 HTTPS; 业务 3000/8080 等开发端口仅临时放行,正式环境禁止对公网暴露,全部由 Nginx 反向代理转发。
ubuntu@服务器公网IP
sudo apt update && sudo apt upgrade -y# 卸载系统自带旧版docker.io,避免官方Docker安装冲突sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 podman-docker containerd runc | cut -f1) -ysudo apt install -y curl wget git vim ufw ca-certificates gnupg lsb-release
海外业务面向欧美:UTC 时区;面向东南亚可设置 Asia/Singapore
sudo timedatectl set-timezone UTC
timedatectl# 东南亚时区可选 sudo timedatectl set-timezone Asia/Singapore
sudo adduser deploysudo usermod -aG sudo deploy
本地电脑生成 ed25519 密钥
ssh-keygen -t ed25519 -C "admin@example.com"
上传公钥至服务器 deploy 用户
ssh-copy-id deploy@服务器公网IP
登录验证密钥可用后,编辑 sshd_config 关闭密码登录、限制 root 远程登录
sudo vim /etc/ssh/sshd_config# 修改配置 PasswordAuthentication no、PermitRootLogin nosudo systemctl reload sshd
云安全组管控公网入口,UFW 做主机内部二次拦截,双重防护。
sudo ufw allow OpenSSHsudo ufw allow 80/tcpsudo ufw allow 443/tcpsudo ufw enablesudo ufw status
sudo install -m 0755 -d /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgsudo chmod a+r /etc/apt/keyrings/docker.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker --versiondocker compose versionsudo systemctl status docker# 将当前用户加入docker组,无需sudo执行docker命令sudo usermod -aG docker $USER
newgrp docker# 测试容器docker run --rm hello-world
容器仅绑定本地 127.0.0.1 端口,禁止直接暴露公网,规避容器漏洞攻击。
mkdir -p ~/webapp/htmlcd ~/webappcat > ~/webapp/html/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tencent Cloud International CVM Demo Site</title>
</head>
<body>
<h1>Web Service Running on Tencent Cloud International CVM</h1>
<p>Docker + Nginx Reverse Proxy Production Deployment Completed</p>
</body>
</html>
EOF
yaml
services:
web:
image: nginx:stable
container_name: web
restart: unless-stopped
volumes:
- ./html:/usr/share/nginx/html:ro
ports:
- "127.0.0.1:8080:80"
networks:
- app_netnetworks:
app_net:
driver: bridge
docker compose up -ddocker compose ps
sudo apt install -y nginxsudo systemctl enable nginxsudo systemctl start nginxsudo systemctl status nginx
sudo vim /etc/nginx/sites-available/example.com
完整配置(新增 HTTP 强制 301 跳转 HTTPS、TLS 安全协议)
nginx
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
# 全部HTTP请求跳转HTTPS
return 301 https://$host$request_uri;}server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
client_max_body_size 20m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
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_set_header Connection "";
}}
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/sudo nginx -tsudo systemctl reload nginx
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com --email admin@example.com --agree-tos --no-eff-email
systemctl list-timers | grep certbotsudo systemctl status certbot.timer# 模拟续期测试,确保无报错sudo certbot renew --dry-run# 查看证书有效期sudo certbot certificates
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。