我已经建立了 TLS 并且它有效。我知道如何在 nginx 中从 http 重写为 https,但我不再使用 nginx。我不知道如何在 Go 中正确执行此操作。
func main() {
certificate := "/srv/ssl/ssl-bundle.crt"
privateKey := "/srv/ssl/mykey.key"
http.HandleFunc("/", rootHander)
// log.Fatal(http.ListenAndServe(":80", nil))
log.Fatal(http.ListenAndServeTLS(":443", certificate, privateKey, nil))
}
func rootHander(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("To the moon!"))
}
我将如何以一种好的方式做到这一点?
慕容森
缥缈止盈
繁华开满天机
相关分类