In Golang, with autocert, I keep seeing examples like this:
server := &http.Server{
Addr: ":https",
Handler: r,
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
},
}
go http.ListenAndServe(":http", certManager.HTTPHandler(nil))
However, I have a server with many sites (go apps) and I use NGINX to proxy the traffic. Can I do something like this?
server := &http.Server{
Addr: ":8443",
Handler: r,
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
},
}
go http.ListenAndServe(":8080", certManager.HTTPHandler(nil))
If not, are there any other solutions for this?
If so, I'm not sure what I could be doing wrong. I do see that one of the returns of the certManager.GetCertificate method is error.
So second part of this question is, how can I catch certManager.GetCertificate's error? My app loads and compiles fine. No errors are thrown.