码迷,mamicode.com
首页 > 其他好文 > 详细

nginx tcp 代理的实现

时间:2018-08-26 19:01:36      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:str   .com   code   实现   HERE   com   guide   http   directive   

但在1.90发布后增加了tcp代理模块 所以无需安装 参考:https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/

实现方式:

stream {
    server {
        listen 6379;
        # ...
        proxy_pass 10.59.87.121:6379;
    }
}

如果报错:
报错1:tcp模块报错
] # /data1/env/nginx/sbin/nginx -t
nginx: [emerg] "stream" directive is not allowed here in /data1/env/nginx/conf/conf.d/tcp.conf:1

原因: strem模块不能放在http的模块内部 ,因为不是http协议.

nginx tcp 代理的实现

标签:str   .com   code   实现   HERE   com   guide   http   directive   

原文地址:http://blog.51cto.com/cuidehua/2164573

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!