minio集群添加FTP后,配置nginx负载均衡

一、环境规划

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

说明:FTP使用TCP协议,使用stream模块转发数据。

二、开始配置
2.1、配置nginx入口。

  • 备份nginx主文件:/etc/nginx/nginx.conf
  • 修改nginx配置文件:/etc/nginx/nginx.conf
  • nginx主配置文件添加stream模块。
  • nginx主配置文件完整如下
user  nginx;
worker_processes  auto;
 
error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    access_log  /var/log/nginx/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    keepalive_timeout  65;
 
    #gzip  on;
 
    include /etc/nginx/conf.d/*.conf;
}
 
stream {
    log_format proxy '$remote_addr [$time_local] '
                     '$protocol $status $bytes_sent $bytes_received '
                     '$session_time "$upstream_addr" '
                     '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
 
    access_log /var/log/nginx/tcp_access.log proxy;
    error_log /var/log/nginx/tcp_error.log;
 
    #包含额外stream配置文件
    include /etc/nginx/stream.d/*.conf;
 
}
  • stream模块添加了子配置目录
  • 创建子配置目录文件,实现真正的业务逻辑。
  • vim /etc/nginx/stream.d/ftp.conf
upstream ftp {
    server 172.16.102.37:8021;
    server 172.16.102.38:8021;
    server 172.16.102.39:8021;
}
 
server {
    listen 8081;
    proxy_pass ftp;
    proxy_timeout 3m;
    proxy_next_upstream on;
    proxy_next_upstream_tries 3;
}

2.2、nginx重启

  • 重新加载配置
    systemctl daemon-reload

  • 重启nginx
    systemctl stop nginx
    systemctl start nginx

2.3、查看nginx监听。8081端口已监听。


image.png

2.4、测试ftp客户端。

  • 找一台服务器安装ftp客户端:172.16.1.39
    yum -y install ftp

  • 通过nginx登录远程ftp服务端

ftp 127.16.102.37 8081
>>输入账号: xxxxxx
>>输入密码:xxxxx
image.png

2.5、nginx配置后,测试上传下载

  • 客户端登录ftp。
  • 使用put命令上传,可以显示成功。
image.png
  • 下载测试
  • 下面2张图可以确认,使用get下载文件正常。


    image.png
image.png

2.6、到此,ftp配置nginx转发后,通过nginx入口,可以正常上传、下载数据。

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

相关阅读更多精彩内容

友情链接更多精彩内容