Serve HTTP and WebSocket with the Same Port and Path in Nginx

Polkadot and other Substrate-based chain nodes supports JSON RPC over HTTP and over WebSocket on ports 9933 and 9944 individually. However, according to the WebSocket handshake, we can determine if the client is requesting WebSocket or other HTTP resource by the header Upgrade: websocket. Here’s a little trick in Nginx to reverse proxy both 9933 (HTTP) and 9944 (WebSocket) with the same host, same port, and same path / location.

February 19, 2021 · Wi1dcard

超简单!基于日志的 Darwinia 验证人节点监控预警

一般来说,监控 Substrate 框架开发的区块链节点,可以使用官方推荐的 Prometheus + Grafana 技术栈。在节点数量比较多的情况下,这套方案的优势比较容易体现出来,我给公司的官方节点也是这么配的。不过近期 Darwinia 主网上线,有不少同事想要跑自己的验证人(validator)节点。对于他们来说: 搭建一套 Prometheus 还要自己调面板和规则,成本实在太高; 只用 PM2、Supervisord、Systemd 之类的守护进程通常只能保证进程没挂,但节点是否正常出块是未知的(例如断网、0 Peer 的情况,节点进程还在,其实已经掉线了)。 为了解决以上这两个问题,我搞了一套非常简易的、基于日志的监控预警方法。

September 29, 2020 · Wi1dcard