nginx4层代理配置:
1、nginx从1.9.0版本开始支持四层代理,但做四层代理时编译需要添加--with-stream模块
#./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_ssl_module--with-http_stub_status_module--with-file-aio--with-stream
2、nginx配置文件
userwww;
worker_processes2;
events{
worker_connections1024;
}
stream{#stram模块和http模块是一同等级;做四层代理时需要添加上这个模块;
server{
listen30028;#30028端口将以4层TCP协议方式转发至后端app_sever;
proxy_passapp_server;
}
upstreamapp_server{
server172.22.0.44:30028;
server172.22.0.45:30028;
}
}
http{
includemime.types;
default_typeapplication/octet-stream;
sendfileon;
keepalive_timeout65;
server{
listen80;
server_namelocalhost;
location/{
roothtml;
indexindex.htmlindex.htm;
}
error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
}
}