To secure Nginx with a Let’s Encrypt SSL certificate on Alpine Linux, you can use the certbot tool. Here are the steps:
- Install certbot:
apk add certbot
- Obtain a SSL certificate:
certbot certonly --standalone -d example.com
- 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;
...
}
- 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