Switch to HTTPS using a self-signed certificate

This commit is contained in:
Moritz Marquardt 2021-07-09 01:15:42 +02:00
parent 373c13baee
commit 13b386d442
No known key found for this signature in database
GPG key ID: D5788327BEE388B6
2 changed files with 35 additions and 6 deletions

View file

@ -80,7 +80,7 @@ func main() {
// Use HOST and PORT environment variables to determine listening address
address := fmt.Sprintf("%s:%s", envOr("HOST", "[::]"), envOr("PORT", "80"))
fmt.Printf("Listening on http://%s\n", address)
fmt.Printf("Listening on https://%s\n", address)
// Enable compression by wrapping the handler() method with the compression function provided by FastHTTP
compressedHandler := fasthttp.CompressHandlerBrotliLevel(handler, fasthttp.CompressBrotliBestSpeed, fasthttp.CompressBestSpeed)
@ -91,9 +91,7 @@ func main() {
fmt.Printf("Couldn't create listener: %s\n", err)
os.Exit(1)
}
if envOr("LETS_ENCRYPT", "0") == "1" {
tls.NewListener(listener, tlsConfig)
}
listener = tls.NewListener(listener, tlsConfig)
// Start the web server
err = (&fasthttp.Server{