nginx -V,下载相同版本nginx解压并编译configure编译时追加参数--with-stream,执行make命令nginx可执行文件,复制objs目录的nginx文件,到nginx sbin 目录nginx.conf, 与http模块同级stream {
upstream mysqlstream {
server 127.0.0.1:3306;
}
server {
listen 13306;#可自定义
proxy_connect_timeout 10s;
proxy_timeout 300s;
proxy_pass mysqlstream;
}
}
stream {
upstream sshstream {
server 127.0.0.1:22;
}
server {
listen 10022;#可自定义
proxy_connect_timeout 10s;
proxy_timeout 300s;
proxy_pass sshstream;
}
}
## 打开防火墙
iptables -I INPUT -p tcp --dport 13306 -j ACCEPT
iptables -I INPUT -p tcp --dport 10022 -j ACCEPT
原文:https://www.cnblogs.com/stringfade/p/15246501.html