| title | Autocert | ||||||
|---|---|---|---|---|---|---|---|
| keywords |
|
||||||
| description | Automatic TLS certificate management. |
This example demonstrates how to set up a secure Go Fiber application using Let's Encrypt for automatic TLS certificate management with autocert.
This project provides a starting point for building a secure web application with automatic TLS certificate management using Let's Encrypt. It leverages Fiber for the web framework and autocert for certificate management.
-
Clone the repository:
git clone https://github.com/gofiber/recipes.git cd recipes/autocert -
Install the dependencies:
go mod download
-
Update the
HostPolicyinmain.gowith your domain:m := &autocert.Manager{ Prompt: autocert.AcceptTOS, HostPolicy: autocert.HostWhitelist("yourdomain.com"), // Replace with your domain Cache: autocert.DirCache("./certs"), }
-
Run the application:
go run main.go
The application should now be running on https://localhost.
-
Open your browser and navigate to
https://yourdomain.com(replace with your actual domain). -
You should see the message:
This is a secure server 👮.
This example provides a basic setup for a Go Fiber application with automatic TLS certificate management using Let's Encrypt. It can be extended and customized further to fit the needs of more complex applications.