1.下载解压nginx
tar -zxvf nginx-1.24.0.tar.gz
2.加载stream模块,编译安装nginx
cd /usr/local/nginx-1.24.0
./configure --prefix=/usr/local/nginx --with-stream
make && make install
3.修改nginx.conf文件,stream与http平级
cd /usr/local/nginx/conf
stream {
upstream ssh{
server 192.168.3.33:22;
}
server {
listen 10022;
proxy_pass ssh;
}
}
4.启动Nginx
cd /usr/local/nginx/sbin
./nginx -c /usr/local/nginx/conf/nginx.conf