静态页面
其实就是复制官网的代码
其中证书 是我自己申请的可以用证书 dingshaohua.com
import fs from "fs";
import http2 from "node:http2";
const server = http2.createSecureServer({
key: fs.readFileSync("/etc/letsencrypt/live/dingshaohua.com/privkey.pem"),
cert: fs.readFileSync("/etc/letsencrypt/live/dingshaohua.com/fullchain.pem"),
});
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'text/html; charset=utf-8',
':status': 200,
});
stream.end('<h1>Hello World</h1>');
});
server.listen(3002);
最终效果如下,访问:https://dingshaohua.com:3002