我使用ListenAndServeTLS
func main() {
serverMux := http.NewServeMux()
serverMux.HandleFunc("/v1/ws1", handler1)
serverMux.HandleFunc("/v1/ws2", handler2)
serverMux.HandleFunc("/v1/ws3", handler3)
serverMux.HandleFunc("/static/", handlerStatic(http.FileServer(http.Dir("/var/project/"))))
go func() {
wsSSLServer := &http.Server{
Addr: ":443",
Handler: serverMux,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
}
certPath := "/etc/letsencrypt/live/example.com/"
fmt.Println(wsSSLServer.ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem"))
}()
wsServer := &http.Server{
Addr: ":80",
Handler: serverMux,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
}
fmt.Println(wsServer.ListenAndServe())
}
现在我在日志中遇到了很多这些错误:
这是什么意思?http2:server:从客户端x.x.x.x读取前言错误:xxxxx: 超时等待客户端序言
答案 0 :(得分:0)
我使用Firefox作为客户端时遇到了同样的错误。 重新生成SSL密钥/证书解决了问题,我猜证书已过期。
对于localhost开发:
openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX -subj '/CN=localhost'