TCP版本的nginx编译

项目中利于Nginx做Thrift的四层代理,实现了nginx对相关thrift服务的负载均衡,现对使用流程做以下总结。

1.搭建nginx编译环境:

   yum -y install gcc gcc-c++ autoconf automake
   yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

2.下载nginx源文件,需要下载1.9.0以上的版本,官方稳定版本为

稳定版本nginx-1.10.1
3.添加tcp支持

  参照官方说明,编译参数中添加--with-steam即可

  进入到nginx源文件目录下

编译脚本如下:

 prefix=/opt/nginx \
--sbin-path=/opt/nginx/sbin/nginx \
--conf-path=/opt/nginx/conf/nginx.conf \
--with-http_stub_status_module \
--with-stream


然后再执行 make && make install即可

4.nginx.conf参数配置如下

  
stream {
    upstream backend {
        hash $remote_addr consistent;

        #server backend1.example.com:12345 weight=5;
        server 192.168.2.121:2565     max_fails=3 fail_timeout=30s;
        #server unix:/tmp/backend3;
    }

    server {
        listen 2565;
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass backend;
    }
 }


5.检查nginx.conf

   ./nginx -t

6.启动nginx

  ./nginx

7.重启nginx

 ./nginx -s reload

8.终止nginx

  kill -9 nginx进程号(有三个)

备注:编译好的版本可从本人上传资源中下载,链接地址:http://download.csdn.net/detail/u012006909/9580156

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值