nginx新增stream模块负载ftp请求

nginx 1.9版本之后直接使用Stream

安装stream模块:

1.nginx 增加tcp
./configure –with-stream (新增配置,其余根据自己需求不变)

2.配置nginx.conf

stream {
upstream ftp {
hash $remote_addr consistent;
server 192.168.1.2:21 max_fails=3 fail_timeout=30s;

server 192.168.1.3:21 max_fails=3 fail_timeout=30s;
}
server {
listen 2121;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass sftp;
}
}