nginx 配置4层转发

user nginx nginx;
worker_processes auto;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;

events {
use epoll;
worker_connections 51200;
multi_accept on;
}

stream {
log_format proxy '$remote_addr [$time_local]'
"$protocol|" "$status|" "$bytes_sent|" "$bytes_received|"
$session_time| "$upstream_addr|"
"$upstream_bytes_sent|" "$upstream_bytes_received|" "$upstream_connect_time|";
access_log /var/log/nginx/tcp-access.log proxy ;
error_log  /var/log/nginx/tcp-error.log warn ;

server {
listen 8080;
proxy_pass test_8080;
proxy_connect_timeout 1s; #后端链接空闲超时断开
proxy_timeout 10s;#后端连接超时时间
}


upstream test_8080 {
server 192.168.137.2:8080 ;
}

}
原文地址:https://www.cnblogs.com/hzcya1995/p/13348336.html