wqt.asia 从域名解析到 HTTPS 部署全过程
wqt.asia: From Domain Setup to HTTPS Deployment
背景
Background
为了展示个人项目和技术博客,决定搭建一个以自己域名为地址的个人网站。目标是:域名能访问、Nginx 托管静态页面、HTTPS 加密。
第一步:域名解析
Step 1: DNS Resolution
在域名管理后台添加两条 A 记录:
@ A 8.162.13.60
www A 8.162.13.60
等待 DNS 生效后,用 nslookup wqt.asia 验证。
第二步:Nginx 配置
Step 2: Nginx Configuration
$ sudo apt update && sudo apt install -y nginx
$ sudo systemctl enable --now nginx
编辑 Nginx 配置:
server {
listen 80;
server_name wqt.asia www.wqt.asia;
root /var/www/wqt.asia;
location / { try_files $uri $uri/ /index.html; }
}
第三步:HTTPS 证书
Step 3: HTTPS Certificate
$ sudo apt install -y certbot python3-certbot-nginx
$ sudo certbot --nginx -d wqt.asia -d www.wqt.asia
踩坑记录
Gotchas
坑 1:www 域名证书申请失败
Gotcha 1: www domain cert failed
原因:只配了 @ 的 A 记录,没配 www。
解决:确保 @ 和 www 都有 A 记录指向同一 IP。
坑 2:安全组未放行 443
Gotcha 2: Port 443 not open in security group
原因:云服务器安全组只放了 80,没放 443。
解决:在云控制台安全组中同时放行 80 和 443。
坑 3:部署后页面没更新
Gotcha 3: Page not updated after deploy
原因:dist 没覆盖到正确的 Nginx root 目录。
解决:确认 Nginx root 指向和 rsync 目标一致,reload 后清除浏览器缓存。
经验总结
Lessons Learned
- 先验证 HTTP 通了再搞 HTTPS
- DNS、安全组、Nginx 是三个最常见卡点
- Certbot 会自动续期,建议用
certbot renew --dry-run测试 - rsync --delete 要小心,确认目标目录是对的
关键命令速查
Quick Command Reference
# DNS
nslookup wqt.asia
# Nginx
sudo nginx -t
sudo systemctl status nginx
# Ports
ss -tlnp | grep -E ':(80|443)\s'
# Cert
sudo certbot certificates
# Renew test
sudo certbot renew --dry-run