Nginx代理TCP请求模块添加及配置步骤
2016-12-14 16:50
387 查看
需求
Nginx 并不支持tcp协议,所以后端的一些基于TCP的业务就只能通过其他高可用负载软件来完成了,如Haproxy。但在1.90发布后增加了tcp代理模块,而老版本nginx需通过附加nginx_tcp_proxy_module实现TCP代理环境
[root@nginx ~]#nginx -Vnginx version:nginx/1.6.0
built by gcc 4.4.720120313 (Red Hat 4.4.7-17) (GCC)
TLS SNI supportenabled
configurearguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module--with-ipv6
步骤
1.下载nginx_tcp_proxy_module-master.ziphttps://github.com/yaoweibin/nginx_tcp_proxy_module
2.解压
unzip nginx_tcp_proxy_module-master.zip
3.平滑添加TCP代理模块
patch -p1 < /root/nginx_tcp_proxy_module-master/tcp.patch
./configure --user=www --group=www--prefix=/usr/local/nginx --with-http_stub_status_module --with-ipv6--add-module=/root/nginx_tcp_proxy_module-master
make #敲黑板,不要make install!!!
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.0719.old
cp objs/nginx/usr/local/nginx/sbin/
make upgrade
4.验证
nginx -V
配置
在nginx.conf文件末尾,即http{}后添加tcp { upstream search { server 10.45.149.215:8111; check interval=3000 rise=2 fall=5 timeout=1000; } server { listen 8111; proxy_pass search; } } |
nginx -t平滑重启
/etc/init.d/nginx reload验证端口是否生效
netstat -nuplt
参考
http://yaoweibin.github.io/nginx_tcp_proxy_module/README.html#ngx_tcp_proxy_modulehttp://zhangge.net/4856.html https://github.com/yaoweibin/nginx_tcp_proxy_module
相关文章推荐
- nginx配置反向代理,文件上传模块
- 用反向代理nginx proxy_pass配置解决ie8 ajax请求被拦截问题 ie8用nginx代理实现跨域请求访问 nginx405正向代理request_uri
- Nginx配置TCP请求转发
- Nginx发布1.9.0版本,新增支持TCP代理和负载均衡的stream模块
- nginx代理TCP模块
- Nginx 代理Http及TCP请求
- nginx添加需要代理的域名 配置
- Nginx 高并发TCP请求Linux系统参数配置
- nginx安装并支持upstream和tcp代理模块
- nginx安装并支持upstream和tcp代理模块
- nginx tcp http 代理配置
- nginx 反向代理配置之---可配置多域名请求
- nginx学习笔记(3):TCP反向代理基本配置
- nginx 代理tcp长连接短连接配置
- Nginx服务器安装,高性能的HTTP、TCP、反向代理、负载均衡等服务和配置
- nginx添加ssl模块配置https
- 腾讯云nginx添加ssl模块并配置https
- Nginx发布1.9.0版本,新增支持TCP代理和负载均衡的stream模块
- Nginx服务器中限制连接数与限制请求的模块配置教程
- Nginx 高并发TCP请求Linux系统参数配置