在Linux上为MinIO配置SSL证书可以确保数据传输的安全性。以下是详细的步骤指南:
首先,你需要一个SSL证书。你可以从Let’s Encrypt免费获取,或者购买一个商业证书。
安装Certbot:
sudo apt update
sudo apt install certbot
获取证书:
sudo certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
按照提示完成证书的获取和安装。
MinIO支持通过环境变量或配置文件来配置SSL。
编辑MinIO的启动脚本(例如minio.sh
),添加以下环境变量:
export MINIO_CERT_FILE="/etc/letsencrypt/live/yourdomain.com/fullchain.pem"
export MINIO_KEY_FILE="/etc/letsencrypt/live/yourdomain.com/privkey.pem"
启动MinIO服务器:
./minio.sh server /data
创建一个配置文件(例如minio-config.json
),内容如下:
{
"certificates": {
"certificateFile": "/etc/letsencrypt/live/yourdomain.com/fullchain.pem",
"keyFile": "/etc/letsencrypt/live/yourdomain.com/privkey.pem"
}
}
启动MinIO服务器时指定配置文件:
./minio.sh server /data --config minio-config.json
启动MinIO服务器后,你可以通过浏览器访问https://yourdomain.com
来验证SSL证书是否正确安装和配置。
Let’s Encrypt证书每90天需要续期一次。你可以使用Certbot的自动续期功能来简化这个过程。
编辑Certbot的续期脚本(例如/etc/letsencrypt/renewal-hooks/deploy/renewal.sh
),添加以下内容:
#!/bin/bash
systemctl restart minio
确保脚本可执行:
chmod +x /etc/letsencrypt/renewal-hooks/deploy/renewal.sh
设置定时任务来自动续期:
sudo crontab -e
添加以下行:
0 0,12 * * * root certbot renew --deploy-hook "/etc/letsencrypt/renewal-hooks/deploy/renewal.sh"
通过以上步骤,你可以在Linux上为MinIO配置SSL证书,确保数据传输的安全性。