1.需要安装stream模块
2.在nginx.conf默认配置文件添加如下配置即可
stream {
log_format tcp '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
upstream i2_rf {
hash $remote_addr consistent;
server 10.0.2.137:6666 max_fails=3 fail_timeout=30s;
server 10.0.2.138:6666 max_fails=3 fail_timeout=30s;
}
server {
listen 6666 so_keepalive=on; ## 系统端口
access_log logs/i2_rf-access.log tcp;
error_log logs/i2_rf-error.log error;
proxy_pass i2_rf;
}
# include stream/*.conf; 另起目录
}