Nginx负载均衡SFTP
安装Nginx
Nginx的tcp依赖模块下载地址https://github.com/yaoweibin/nginx_tcp_proxy_module
[root@localhost nginx-1.18.1]# yum -y install pcre*
[root@localhost nginx-1.18.1]# yum -y install openssl*
[root@localhost nginx-1.18.1]# yum -y install gcc
[root@localhost nginx-1.18.1]# patch -p1 < /root/nginx_tcp_proxy_module-master/tcp.patch
导入tcp模块包需要在解压后的nginx源码包中执行导入patch命令
[root@localhost nginx-1.18.1]# ./configure --add-module=/root/nginx_tcp_proxy_module-master
[root@localhost nginx-1.18.1]# make
[root@localhost nginx-1.18.1]# make install
配置Nginx
user nginx nginx;
worker_processes 4;
events {
worker_connections 512000;
}
tcp {
upstream sftp {
server 192.168.50.11:22;
server 192.168.50.12:22;
check interval=3000 rise=2 fall=2 timeout=1000;
}
server {
listen 8080;
proxy_pass sftp;
}
}
添加用户
[root@localhost nginx-1.8.1]# useradd nginx
启动nginx
[root@localhost nginx-1.8.1]# /usr/local/nginx/sbin/nginx
添加用户
[root@localhost nginx-1.8.1]# useradd nginx
启动nginx
[root@localhost nginx-1.8.1]# /usr/local/nginx/sbin/nginx