• NGINX 加载动态模块(NGINX 1.9.11开始增加加载动态模块支持)


    NGINX 1.9.11开始增加加载动态模块支持,从此不再需要替换nginx文件即可增加第三方扩展。目前官方只有几个模块支持动态加载,第三方模块需要升级支持才可编译成模块。

    tinywan@tinywan:~/nginx-1.12.0$ ./configure --help | grep dynamic
      --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
      --with-http_image_filter_module=dynamic
                                         enable dynamic ngx_http_image_filter_module
      --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
      --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
      --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
      --with-stream=dynamic              enable dynamic TCP/UDP proxy module
      --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
      --add-dynamic-module=PATH          enable dynamic external module
      --with-compat                      dynamic modules compatibility

    如上可看出官方支持9个动态模块编译,需要增加第三方模块,使用参数--add-dynamic-module=即可。

    NGINX动态模块语法:

    load_module

    Default: —

    配置段: main

    说明:版本必须>=1.9.11

    实例:load_module modules/ngx_mail_module.so;

    编译安装

     查看编译生成的模块

    tinywan@tinywan:/usr/local/nginx/modules$ ls
    ngx_http_xslt_filter_module.so  ngx_rtmp_module.so  ngx_stream_module.so

    查看编译生成的模块

     配置文件

    不加载模块配置文件nginx.conf 最末尾添加

    worker_processes  1;
    load_module "modules/ngx_rtmp_module.so";
    load_module "modules/ngx_stream_module.so";
    events {
        worker_connections  1024;
    }
    
    stream {
        upstream rtmp {
            server 127.0.0.1:8089; # 这里配置成要访问的地址
            server 127.0.0.2:1935;
            server 127.0.0.3:1935; #需要代理的端口,在这里我代理一一个RTMP模块的接口1935
        }
        server {
            listen 1935;  # 需要监听的端口
            proxy_timeout 20s;
            proxy_pass rtmp;
        }
    }
    
    http {
        include       mime.types;
        ...
    }
    
    rtmp {
        server {
            listen 1935;
    
            application mytv {
                live on;
            }
        }
    }

    启动Nginx,提示错误,表示没有加载模块进去

  • 相关阅读:
    AutoFac学习笔记
    AutoMapper学习笔记
    ROSLYN 查看C#方法执行次数
    log4net 动态创建文件名
    WPF可切换按钮,iOS风格
    咕咕咕
    贪吃的小J
    UK Day15
    UK Day15
    UK Day15
  • 原文地址:https://www.cnblogs.com/tinywan/p/6965467.html
Copyright © 2020-2023  润新知