先上minio 官网地址
https://docs.min.io/
docker 一键搭建
docker run -p 9000:9000 -p 50000:50000 --name minio1
-e “MINIO_ACCESS_KEY=admin” \
-e “MINIO_SECRET_KEY=12345678”
-v /mnt/data:/data \ 挂载数据地址
-v /mnt/config:/root/.minio \ 配置文件地址
minio/minio server /data --console-address “:50000” 指定minio服务
如果需要使用https协议
配置https
在${HOME}.minio/certs文件夹下
1、生成私钥
openssl genrsa -out private.key 2048
2、生成自签名证书
创建一个以openssl.conf以下内容命名的文件。设置IP.1和/或DNS.1指向正确的 IP/DNS 地址:
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = US
ST = VA
L = Somewhere
O = MyOrg
OU = MyOU
CN = MyServerName
[v3_req]
subjectAltName = @alt_names
[alt_names]
IP.1 = 127.0.0.1 这里需要匹配docker内ip
DNS.1 = localhost
然后指定文件运行
openssl req -new -x509 -nodes -days 730 -key private.key -out public.crt -config openssl.conf
重启minio服务即可支持https
如果想换回http,删掉或重命名private.key密钥文件即可
给出 nodejs 测试 用例 具体 内容 参考官网
var Minio = require(“minio”);
// Instantiate the minio client with the endpoint
// and access keys as shown below.
var minioClient = new Minio.Client({
endPoint: “192.168.1.84”, //这里不能带http或者https
port: 9000,
useSSL: true, //不需要https
accessKey: “admin”, //账号密码同web登陆时一致
secretKey: “12345678”,
});
// File that needs to be uploaded.
var file = “D:\test.zip”;
// Make a bucket called europetrip.
minioClient.makeBucket(“europetrip”, “us-east-1”, function (err) {
if (err) return console.log(err);
console.log(‘Bucket created successfully in “us-east-1”.’);
var metaData = {
“Content-Type”: “application/octet-stream”,
“X-Amz-Meta-Testing”: 1234,
example: 5678,
};
// Using fPutObject API upload your file to the bucket europetrip.
minioClient.fPutObject(
“europetrip”,
“test.zip”,
file,
metaData,
function (err, etag) {
if (err) return console.log(err);
console.log(“File uploaded successfully.”);
}
);
});