首页 > 代码库 > Nginx负载均衡SFTP

Nginx负载均衡SFTP

1、CentOS安装SFTP,参考

2、Nginx-1.8.1 下载 ,Nginx_TCP插件 下载 

3、安装Nginx

[root@localhost nginx-1.8.1]# yum -y install pcre*
[root@localhost nginx-1.8.1]# yum -y install openssl*
[root@localhost nginx-1.8.1]# patch -p1 < /root/nginx_tcp_proxy_module-master/tcp.patch
[root@localhost nginx-1.8.1]# ./configure --add-module=/root/nginx_tcp_proxy_module-master
[root@localhost nginx-1.8.1]# make
[root@localhost nginx-1.8.1]# make install

4、配置Nginx

user  nginx nginx;
worker_processes  4;

events {
worker_connections  512000;
}

tcp {

    upstream sftp{
        server 192.168.208.141:22;
        server 192.168.208.142:22;
        check interval=3000 rise=2 fall=5 timeout=1000;
    }

    server {
        listen 8080;
        proxy_pass sftp;
    }

}

5、添加nginx用户

[root@localhost nginx-1.8.1]# useradd nginx

6、启动Nginx

[root@localhost nginx-1.8.1]# /usr/local/nginx/sbin/nginx

7、关闭防火墙

[root@localhost nginx-1.8.1]# service iptables stop

8、winscp连接

技术分享

 

参考资料:

http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=29791971&id=4702007

http://www.voidcn.com/blog/anonxiaozi/article/p-5529154.html

https://github.com/yaoweibin/nginx_tcp_proxy_module

 

Nginx负载均衡SFTP