nginx負載均衡,minio集群

一、環(huán)境準備

節(jié)點 IP地址 節(jié)點系統(tǒng)
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服務(wù)管理

systemctl start nginx     #啟動
systemctl enable nginx    #開機自啟
systemctl status nginx    #查看狀態(tài)
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
  • 三臺服務(wù)器配置負載均衡
  • 使用反向代理連接服務(wù)器
  • 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集群部署鏈接:http://www.itdecent.cn/p/10e38eb968dd

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容