需求:生产有个接口是通过socket通信。nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信。

实现方法:Centos7.2下yum直接安装的nginx,添加新模块支持tcp转发;重新编译Nginx并添加 --with-stream 参数。

实现过程:

1.  查看nginx版本模块

[root@pre ~]# nginx -V

2.  下载一个同版本可编译的Nginx

cd /opt
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xf nginx-1.12..tar.gz && cd nginx-1.12.

3.  备份原Nginx文件

mv /usr/sbin/nginx /usr/sbin/nginx.bak
cp -r /etc/nginx{,.bak}

4.  重新编译Nginx

根据第1步查到已有的模块,加上本次需新增的模块: --with-stream

cd /opt/nginx-1.12.

./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --with-stream

以上编译时,如出现缺少依赖,一般需要安装以下模块,安装完再次编译:

yum -y install libxml2 libxml2-dev libxslt-devel
yum -y install gd-devel
yum -y install perl-devel perl-ExtUtils-Embed
yum -y install GeoIP GeoIP-devel GeoIP-data
yum -y install pcre-devel
yum -y install openssl openssl-devel gperftools

5.  编译通过,继续验证 
继续输入:make  
make完成后不要继续输入“make install”,以免现在的nginx出现问题 
以上完成后,会在objs目录下生成一个nginx文件,先验证:

/opt/nginx-1.12./objs/nginx -t
/opt/nginx-1.12./objs/nginx -V

6.  替换Nginx文件并重启

cp /opt/nginx-1.12./objs/nginx /usr/sbin/
nginx -s reload

7.  检查

[root@pre ~]# nginx -V


添加模块成功!!!

yum安装的Nginx添加第三方模块支持tcp的更多相关文章

  1. 已安装的nginx添加其他模块

    总体操作就是添加新模块并重新编译源码,然后把编译后的nginx可执行文件覆盖原来的那个即可.1 查看已安装的参数nginx -V拷贝那些巴拉巴拉的参数,后面编译的时候使用 2 下载相同版本号的源码,解 ...

  2. nginx添加第三方模块

    原已经安装好的nginx,现在需要添加一个未被编译安装的模块: nginx -V 可以查看原来编译时都带了哪些参数,看看nginx是哪个版本,去下载一个nginx的源码,解压 原来的参数:--pref ...

  3. yum安装下的nginx,如何添加模块,和添加第三方模块

    需求:生产有个接口是通过socket通信.nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信. 实现方法:Centos7.2下yum直接安装的nginx, ...

  4. 给已安装的NGINX添加新的模块

    给已安装的NGINX添加新的模块 2018-11-16 14:02:45   Visit  0 使用 nginx -V 查看当前nginx的信息,包括版本号和configure编译配置信息 版本号 : ...

  5. nginx增加第三方模块

    增加第三方模块 ============================================================ 一.概述nginx文件非常小但是性能非常的高效,这方面完胜ap ...

  6. nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下)

    nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下),安装Nginx和HttpAccessKeyModule模块(参考LNMP环境 ...

  7. Debian 为nginx增加第三方模块

    为nginx增加第三方模块需要重新编译nginx的,但是debian在安装nginx的时候做了很多事情,比如systemd,/etc/nginx/里的各种文件,所以我们最好在debian源代码包的基础 ...

  8. CentOS 使用官方源yum安装最新nginx版本

    CentOS 使用官方源yum安装最新nginx版本 1.创建nginx.repo # vi /etc/yum.repos.d/nginx.repo 2.添加内容#如果是CentOS6,文件内容如下: ...

  9. Python-Windows下安装BeautifulSoup和requests第三方模块

    http://blog.csdn.net/yannanxiu/article/details/50432498 首先给出官网地址: 1.Request官网 2.BeautifulSoup官网 我下载的 ...

随机推荐

  1. sql字符串根据日期产生日期+自增长标志

    select Convert(varchar(6), '20180614 20:19:04', 12) + SubString('0000' + Convert(varchar(6), 1 + 1), ...

  2. SpringBoot+mybatis:报错Fri Oct 19 14:29:24 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requiremen

    报错:Fri Oct 19 14:29:24 CST 2018 WARN: Establishing SSL connection without server's identity verifica ...

  3. web api 安全

    这方面的文章已经有很多了,我只是记录一下自己在项目中应用的具体实现 客户端 DateTime t = DateTime.Now; long timeStamp = SignHelper.Convert ...

  4. MySQL ERROR 1130 (HY000): Host '192.168.1.8' is not allowed to connect to this MySQL server

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.8' IDENTIFIED BY 'www.linuxidc.com' WITH GRANT OPTI ...

  5. 『高性能模型』HetConv: HeterogeneousKernel-BasedConvolutionsforDeepCNNs

    论文地址:HetConv 一.现有网络加速技术 1.卷积加速技术 作者对已有的新型卷积划分如下:标准卷积.Depthwise 卷积.Pointwise 卷积.群卷积(相关介绍见『高性能模型』深度可分离 ...

  6. 判断PDF文件是否相同(通过二进制流判断)

    一.Java代码 1.将PDF转为字节流    /*     * @step     *  1.使用BufferedInputStream和FileInputStream从File指定的文件中读取内容 ...

  7. Element-ui框架checkbox复选框回显

    先看下效果是不是你需要的..... 然后废话不多说,上代码,希望能够帮助到你... <template> <div class=''> <el-form label-wi ...

  8. 微信小程序1rpx border ios真机显示不全问题

    无意间测试发现,把border的颜色的透明度颜色改成0.99就可以了.1就不行. 边框显示不全的写法: border:1rpx solid rgba(244,84,80,1); 将边框代码的透明度改成 ...

  9. web前端bug积累

    在将img转换为canvas时,在firefox中,如果img引用的svg使用了fill=(#id),此fill是无效的,可能导致整个转换失效,html2canvas.js也不行.chrome有效,其 ...

  10. element-ui <el-select> + <el-option> 回显格式为中文 传值格式为对应value

    <template> <!-- 需求:使用 <el-select> + <el-option> 关于下拉选择 前端显示中文,传值为对应格式value --&g ...