Ubuntu MinIO如何配置SSL证书

在Ubuntu上为MinIO配置SSL证书,可以按照以下步骤进行:

方法一:使用Let’s Encrypt

  1. 安装Certbot
    Certbot是一个自动化的工具,用于获取和续订Let’s Encrypt证书。

    sudo apt update
    sudo apt install certbot python3-certbot-nginx
    
  2. 获取证书
    使用Certbot获取SSL证书。假设你的MinIO服务器运行在minio.example.com上。

    sudo certbot --nginx -d minio.example.com
    

    Certbot会自动配置Nginx以使用新获取的证书。

  3. 配置MinIO使用SSL
    编辑MinIO的配置文件(通常是/etc/minio/minio.conf),添加以下内容:

    [server]
    address = :9000
    secure = true
    
  4. 重启MinIO服务

    sudo systemctl restart minio
    

方法二:手动配置SSL证书

  1. 获取SSL证书
    你可以从Let’s Encrypt或其他证书颁发机构获取SSL证书。假设你已经有了证书文件fullchain.pem和私钥文件privkey.pem

  2. 配置Nginx
    编辑Nginx配置文件(通常是/etc/nginx/sites-available/minio),添加以下内容:

    server {
        listen 443 ssl;
        server_name minio.example.com;
    
        ssl_certificate /path/to/fullchain.pem;
        ssl_certificate_key /path/to/privkey.pem;
    
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:!aNULL:!MD5;
    
        location / {
            proxy_pass http://localhost:9000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
    
    server {
        listen 80;
        server_name minio.example.com;
    
        location / {
            return 301 https://$host$request_uri;
        }
    }
    

    确保将/path/to/fullchain.pem/path/to/privkey.pem替换为实际的证书文件路径。

  3. 启用Nginx配置

    sudo ln -s /etc/nginx/sites-available/minio /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx
    
  4. 配置MinIO使用SSL
    编辑MinIO的配置文件(通常是/etc/minio/minio.conf),添加以下内容:

    [server]
    address = :9000
    secure = true
    
  5. 重启MinIO服务

    sudo systemctl restart minio
    

验证配置

确保Nginx和MinIO都正确配置并运行后,你可以通过浏览器访问https://minio.example.com来验证SSL证书是否生效。

通过以上步骤,你应该能够在Ubuntu上成功为MinIO配置SSL证书。