Step 1. h2是基于ssl加密传输必须要有证书
Step 2. 证书可上阿里云免费申请, 或使用openssl工具生成自签名证书
Step 3. nodejs加载http2模块
Step 4. 使用http2.createSecureServer方法创建h2连接

openssl证书生成命令

openssl req -newkey rsa:2048 -nodes -keyout rsa_private.key -x509 -days 365 -out cert.crt

nodejs配置http2

也可用pem模块生成

nodejs配置http2
注意: 如果是使用阿里云服务别忘了添加规则打开入口443端口访问权限

相关文章:

  • 2021-10-02
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-10-13
猜你喜欢
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-08-11
  • 2021-07-29
相关资源
相似解决方案