Skip to content
TrySitePrice

How to secure Nginx with Let’s Encrypt certificate on Alpine Linux

Best/Tutorial

To secure Nginx with a Let's Encrypt SSL certificate on Alpine Linux, you can use the certbot tool. Here are the steps:

  1. Install certbot:

apk add certbot

  1. Obtain a SSL certificate:

certbot certonly --standalone -d example.com

  1. Update Nginx configuration to use the SSL certificate:

Add the following lines to the Nginx server block configuration file, typically located at /etc/nginx/nginx.conf:

server {

 listen 443 ssl;

 server_name example.com;

 ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;

 ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

 ...

}

  1. Restart Nginx to apply the changes:

/etc/init.d/nginx restart

Now Nginx should be secured with a Let's Encrypt SSL certificate on your Alpine Linux system. Remember to renew the SSL certificate before it expires by running the following command:

certbot renew