单机部署minio,设置Nginx代理,配置https(TLS)访问
安装
下载地址:https://dl.min.io/
# 创建目录
mkdir -p /usr/local/minio/{data,bin,etc}
# 下载minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio -P /usr/local/minio/bin/
# 授予minio文件执行权限
cd /usr/local/minio/bin && chmod +x minio
# 创建minio用户
useradd -s /sbin/nologin -d /var/lib/minio minio
# 更改minio相关目录、文件的所有者、所有组
chown -R minio:minio /usr/local/minio/
# 创建配置文件:/usr/local/minio/etc/minio.conf
MINIO_VOLUMES="/usr/local/minio/data"
#端口:默认9000
MINIO_OPTS="--address ':9000' --console-address ':9001' --config-dir /usr/local/minio/etc/"
#登录名
#MINIO_ACCESS_KEY=minio #过期配置
MINIO_ROOT_USER=minio
#登录密码
#MINIO_SECRET_KEY=minio #过期配置
MINIO_ROOT_PASSWORD=minio
# 创建service文件:/etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/minio/bin/minio
[Service]
# User and group
User=minio
Group=minio
EnvironmentFile=/usr/local/minio/etc/minio.conf
ExecStart=/usr/local/minio/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
# 重新加载、生效minio.service文件(以上两个文件配置发生变更后需要执行)
systemctl daemon-reload
# 启动、关闭、查看进程状态、开机启动
systemctl start minio
systemctl stop minio
systemctl status minio
systemctl enable minio.service
# 防火墙放行端口:9000
firewall-cmd --zone=public --add-port=9000/tcp --permanent
firewall-cmd --zone=public --add-port=9001/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
# 查看minio服务日志
journalctl -u minio.service
# 倒序查看日志
journalctl -r -u minio.service
# 查看时间段内的服务日志
journalctl --since "2020-01-01 20:00:00" --until "2020-02-01 20:15:00"
为MinIO Server设置Nginx代理
参考文档:http://docs.minio.org.cn/docs/master/setup-nginx-proxy-with-minio
参考另一篇文章:https://www.cnblogs.com/sanduzxcvbnm/p/15988362.html
注:nginx和minio是安装在同一系统上的
修改nginx配置文件 /usr/local/nginx/conf/nginx.conf
upstream minio_gateway {
server 127.0.0.1:9000 weight=1 max_fails=2 fail_timeout=10s;
}
server {
listen 19000;
server_name localhost:19000;
location / {
proxy_set_header Host $http_host;
proxy_pass http://minio_gateway;
}
}
我这边对外提供访问minio的端口号是19000,当浏览器访问 IP:19000 时,nginx会代理转发给 minio_gateway (即 localhost:9000)
登录账号名、密码 见 /usr/local/minio/etc/minio.conf
中的 MINIO_ROOT_USER、MINIO_ROOT_PASSWORD
配置Minio服务使用TLS
# 查看本机ip
# ip addr
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:6a:65:07 brd ff:ff:ff:ff:ff:ff
inet 192.168.20.102/24 brd 192.168.20.255 scope global noprefixroute dynamic ens32
valid_lft 1547sec preferred_lft 1547sec
inet6 fe80::45cc:6455:6bb0:4d86/64 scope link noprefixroute
valid_lft forever preferred_lft forever
我的IP是:192.168.20.102
# 编辑文件 /etc/pki/tls/openssl.cnf
找到[ v3_ca ],新增一行: subjectAltName=IP:192.168.20.102
# 不编辑openssl.cnf文件的后果就是:minio控制台登录不了
# 创建目录/usr/local/minio/etc/certs 后进入,如果已存在可直接进入,在当前目录使用 OpenSSL 来生成私钥文件和自签名证书
生成私钥: openssl genrsa -out private.key 2048
生成自签名证书: openssl req -new -x509 -days 3650 -key private.key -out public.crt -subj "/C=US/ST=state/L=location/O=organization/CN=domain"
最后检查/usr/local/minio/etc/certs目录是否属于minio:minio,如果不是就需要执行以下命令: chown -R minio:minio /usr/local/minio/etc/certs
# 重新启动minio
systemctl restart minio