Do I need to use nginx or Apache to use Lets Encrypt?

I have a really simple golang based API that just listens for the path and responds accordingly to the database insert.

I want to use it through TLS / https using Lets Encrypt, but all the tutorials seem to point to using Apache or nginx as a requirement.

I like to maintain my server is actually lighter and did not see the need to enter the overhead on these web servers (this is definitely not a full website), and it works well on http implementation.

Is it possible to install it without Apache or nginx?

+4
source share
1

, Apache/Nginx, Go TLS.

http.ListenAndServeTLS

:

➜ sudo letsencrypt certonly --standalone --agree-tos --email you@email.com -d domain1.com [-d domain2.com, etc..]
➜ sudo cat /etc/letsencrypt/archive/domain1.com/fullchain1.pem > cert.pem
➜ sudo cat /etc/letsencrypt/archive/domain1.com/privkey1.pem > key.pem 

➜ cat main.go
import (
    "log"
    "net/http"
)

func handler(w http.ResponseWriter, req *http.Request) {
    w.Header().Set("Content-Type", "text/plain")
    w.Write([]byte("This is an example server.\n"))
}

func main() {
    http.HandleFunc("/", handler)
    log.Printf("About to listen on 10443. Go to https://domain1.com:10443/")
    log.Fatal(http.ListenAndServeTLS(":10443", "cert.pem", "key.pem", nil))
}

, , goa 443 ( https), root, systemd, .

443:

  • log.Fatal(http.ListenAndServeTLS(":443", "cert.pem", "key.pem", nil))

  • go build

  • sudo ./your-package-name
  • root, chown cert.pem/key.pem, setcap cap_net_bind_service=+ep your-package-name, 443/80 .

setcap: https://wiki.apache.org/httpd/NonRootPortBinding

+4

All Articles