Skip to content

How can I use Custom TLSConfig with AutoTLS? #2403

Answered by aldas
eranchetz asked this question in Q&A
Discussion options

You must be logged in to vote

Echo docs have example for autoTLS https://echo.labstack.com/cookbook/auto-tls/#server see customHTTPServer function there

I would recommend using http.Server + autocert.Manager as it allows you to customize more aspects of server.

func main() {
	e := echo.New()
	e.Use(middleware.Recover())
	e.Use(middleware.Logger())
	e.GET("/", func(c echo.Context) error {
		return c.HTML(http.StatusOK, `
			<h1>Welcome to Echo!</h1>
			<h3>TLS certificates automatically installed from Let's Encrypt :)</h3>
		`)
	})

	autoTLSManager := autocert.Manager{
		Prompt: autocert.AcceptTOS,
		// Cache certificates to avoid issues with rate limits (https://letsencrypt.org/docs/rate-limits)
		Cache: autocert.DirC…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eranchetz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants