零基础上手WebGIS+智慧校园实例(1)【html by js】

阎小妍

关注

阅读 4

2024-11-18

域名绑定与 Docker 容器部署指南

1. 获取云服务器公网 IP

  1. 登录云服务提供商控制台
  2. 记录服务器公网 IP(例:123.456.78.90

2. 配置域名 DNS 解析

  1. 登录域名注册商控制台
  2. 添加 A 记录:
    • 主机记录:@
    • 类型:A
    • 值:服务器公网 IP
    • TTL:默认

3. 安装 Nginx

sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

4. 配置 Nginx 反向代理

  1. 创建配置文件:
sudo nano /etc/nginx/sites-available/【你的域名】
  1. 配置内容:
server {
    listen 80;
    server_name 【你的域名】 www.【你的域名】;
    location / {
        proxy_pass http://localhost: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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
  1. 启用配置:
sudo ln -s /etc/nginx/sites-available/【你的域名】 /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

5. 配置防火墙

sudo ufw status
sudo ufw allow 'Nginx Full'
sudo ufw status

6. 测试域名访问

在浏览器访问:http://【你的域名】

7. 配置 HTTPS(可选)

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d 【你的域名】 -d www.【你的域名】
sudo certbot renew --dry-run

参考资源

  • Nginx 官方文档
  • Let’s Encrypt 官方文档

注:所有【你的域名】部分需替换为实际域名

精彩评论(0)

0 0 举报