VPS 安装的好处是不影响本机的环境和占用本机性能,不需要时也可以随时释放。
VPS 准备
申请一个 VPS 服务器
本文测试时使用的环境如下
阿里云 HK
系统:Ubuntu 18.04
配置:2核4G
硬盘:默认 40G 系统盘
建议海外服务器,安装速度较快
安装
参考 substrate kitties 教程安装
https://substrate.dev/substrate-collectables-workshop/#/zh-cn/0/setup
配置 wss
安装 ngnix
sudo apt-get install nginx
安装 certbot
https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx.html
修改 nginx 配置 /etc/nginx/site-available/default
server {
server_name test.substrate.cc; # managed by Certbot
location / {
try_files $uri $uri/ =404;
proxy_pass http://localhost:9944;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.substrate.cc/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.substrate.cc/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
重启nginx
sudo service nginx restart
启动 substrate
通过 Screen 或 PM2 启动
./target/release/substratekitties --dev
测试
如果你配置的域名是 wss://test.substrate.cc
可以访问 https://test.substrate.cc
如果页面输出
“WebSocket Protocol Error: Unable to parse WebSocket key.”
则应该已经配置好了,接下去用 https://polkadot.js.org/apps/ 测试连接即可。
原文
http://blog.boka.network/2020/02/17/ru-he-zai-vps-shang-chuang-jian-yi-ge-substrate-10/
网友评论