静看光阴荏苒
不管不顾不问不说也不念

搭建3D版COVID-19病例数据地图

随着COVID-19的世界大流行,Gayhub上面也陆陆续续有很多关于这个病毒的有趣项目了。。

这是我搭建的一个演示站:https://covid19.233.fi/(24h删除)

以下步骤使用Debian10操作,首先安装curl/git/nginx/certbot/nodejs:

apt -y update
apt -y install build-essential curl git nginx python-certbot-nginx
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt -y install nodejs

拉取项目源码:

cd /opt
git clone https://github.com/sorxrob/covid3d.git
cd covid3d

编辑如下文件:

nano /opt/covid3d/src/constants.js

将CASES_API这段代码修改为下面的样子(自己准备一个域名)

export const CASES_API =
  'https://covid19-api.233.fi';

如图所示:

安装前端依赖并构建资源用于生产:

npm install
npm run build

安装后端依赖:

cd backend
npm install

新建一个systemd服务用于守护后端:

nano /lib/systemd/system/covid19-api.service

写入如下配置:

[Unit]
Description=Covide19 API Service
After=network.target

[Service]
WorkingDirectory=/opt/covid3d/backend
ExecStart=/usr/bin/npm start
Restart=on-failure
User=root

[Install]
WantedBy=multi-user.target

启动后端:

systemctl start covid19-api.service

新建用于前端的nginx配置文件:

nano /etc/nginx/conf.d/covid19.conf

写入如下配置:

server {
    listen       80;
    server_name  covid19.233.fi; # 换成你的域名
    index        index.html;
    root         /opt/covid3d/dist;
    client_max_body_size 128G;
}

新建用于反代后端的nginx配置文件:

nano /etc/nginx/conf.d/covid19-api.conf

写入如下配置:

server {
    listen       80;
    server_name  covid19-api.233.fi; # 换成你的域名

location / {
    proxy_pass       http://178.170.68.186:3030; # 换成你的服务器公网IP
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
    }
}

使用certbot签发SSL证书:

certbot --nginx --agree-tos --no-eff-email --email xxxxx@qq.com

最后设置nginx和covid19-api开机自启:

systemctl enable nginx covid19-api

演示:

赞(8)
未经允许不得转载:荒岛 » 搭建3D版COVID-19病例数据地图
分享到: 更多 (0)

评论 10

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    好像挺有趣的一个项目,马上去试试。 :idea:

    Foliage4年前 (2020-04-27) Chrome 81.0.4044.124 Chrome 81.0.4044.124 iPad iOS 13.4 iPad iOS 13.4回复
  2. #2

    寻衅滋事警告 :razz:

    橘子4年前 (2020-04-27) Google Chrome 75.0.3770.124 Google Chrome 75.0.3770.124 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 我寻啥衅滋啥事了嘛,瞧这地图上面的天朝确诊病例数量还没天朝官方报告的多,明明是为天朝减负呢 :razz:

      LALA4年前 (2020-04-29) Google Chrome 81.0.4044.92 Google Chrome 81.0.4044.92 Windows 10 x64 Edition Windows 10 x64 Edition回复
  3. #3

    好奇怪打开网页没有数据显示 :grin:

    Foliage4年前 (2020-04-28) Chrome 81.0.4044.124 Chrome 81.0.4044.124 iPad iOS 13.4 iPad iOS 13.4回复
    • 那应该就是后端API没搭建好。。

      LALA4年前 (2020-04-29) Google Chrome 81.0.4044.92 Google Chrome 81.0.4044.92 Windows 10 x64 Edition Windows 10 x64 Edition回复
  4. #4

    台湾这个……博主你还是赶紧删掉网站比较好

    言箬4年前 (2020-04-29) Google Chrome 83.0.4100.0 Google Chrome 83.0.4100.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 好的,待会就删了。

      LALA4年前 (2020-04-29) Google Chrome 81.0.4044.92 Google Chrome 81.0.4044.92 Windows 10 x64 Edition Windows 10 x64 Edition回复
  5. #5

    新图床玩具:https://github.com/LycheeOrg/Lychee

    s84年前 (2020-04-29) Google Chrome 81.0.4044.129 Google Chrome 81.0.4044.129 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 这个程序很早就有了,看来是最近用Laravel重写了。。

      LALA4年前 (2020-04-30) Google Chrome 81.0.4044.92 Google Chrome 81.0.4044.92 Windows 10 x64 Edition Windows 10 x64 Edition回复

分享创造快乐

广告合作资源投稿