nginx负载均衡,minio集群

一、环境准备

节点 IP地址 节点系统
nginx 172.16.102.37 Centos7.9.2009

二、安装nginx

2.1、* 下载rpm包

wget https://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.24.0-1.el7.ngx.x86_64.rpm

2.2、安装nginx

  • 默认安装路径:/etc/nginx
rpm -ivh nginx-1.24.0-1.el7.ngx.x86_64.rpm
image.png

2.3、nginx服务管理

systemctl start nginx     #启动
systemctl enable nginx    #开机自启
systemctl status nginx    #查看状态
image.png

2.4、浏览器访问80端口,nginx正常。


image.png

三、配置nginx

3.1、修改配置文件

  • 进入扩展文件配置目录/etc/nginx/conf.d
  • 将默认配置文件default.conf删除或者修改名字

3.2、新增扩展文件

  • vim /etc/nginx/conf.d/minio.conf
  • 三台服务器配置负载均衡
  • 使用反向代理连接服务器
  • 9000端口为api
  • 9001为web控制台端口
upstream minio_s3 {
   least_conn;
   server 172.16.1.37:9000;
   server 172.16.1.37:9000;
   server 172.16.1.37:9000;
}
 
upstream minio_console {
   least_conn;
   server 172.16.1.37:9001;  
   server 172.16.1.38:9001;
   server 172.16.1.39:9001;  
}
 
server {
   listen       80;
   listen  [::]:80;
   server_name  172.16.1.37;
 
   # Allow special characters in headers
   ignore_invalid_headers off;
   # Allow any size file to be uploaded.
   # Set to a value such as 1000m; to restrict file size to a specific value
   client_max_body_size 0;
   # Disable buffering
   proxy_buffering off;
   proxy_request_buffering off;
 
   location / {
      proxy_set_header Host $http_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;
      proxy_set_header X-NginX-Proxy true;
 
      # This is necessary to pass the correct IP to be hashed
      real_ip_header X-Real-IP;
      proxy_connect_timeout 300;
      # To support websockets in MinIO versions released after January 2023
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
      # Uncomment the following line to set the Origin request to an empty string
      proxy_set_header Origin '';
      chunked_transfer_encoding off;
 
      proxy_pass http://minio_console; # This uses the upstream directive definition to load balance
   }
}
 
server {
   listen       8080;
   listen  [::]:8080;
   server_name  172.16.1.37;
 
   # Allow special characters in headers
   ignore_invalid_headers off;
   # Allow any size file to be uploaded.
   # Set to a value such as 1000m; to restrict file size to a specific value
   client_max_body_size 0;
   # Disable buffering
   proxy_buffering off;
   proxy_request_buffering off;
 
   location / {
      proxy_set_header Host $http_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;
      proxy_set_header X-NginX-Proxy true;
 
      # This is necessary to pass the correct IP to be hashed
      real_ip_header X-Real-IP;
      proxy_connect_timeout 300;
      # To support websockets in MinIO versions released after January 2023
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
      # Uncomment the following line to set the Origin request to an empty string
      proxy_set_header Origin '';
      chunked_transfer_encoding off;
 
      proxy_pass http://minio_s3; # This uses the upstream directive definition to load balance
   }
}

3.3、测试web控制台

  • 浏览器登录:http://172.16.1.37
  • 账号:xxxxxxxx(默认账密:minioadmin)
  • 密码:xxxxxxxx


    image.png

备注:minio集群部署链接:https://www.jianshu.com/p/10e38eb968dd

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容