nginx编译时添加额外第三方模块

2024-01-08 18:51:20

比如要添加第三方流量监控模块nginx-module-vts

1、官网

官网 Releases · vozlt/nginx-module-vts · GitHubNginx virtual host traffic status module. Contribute to vozlt/nginx-module-vts development by creating an account on GitHub.icon-default.png?t=N7T8https://github.com/vozlt/nginx-module-vts/releases2、下载nginx-module-vts

找个合适的zip包下载,这里给给0.2.2版本的下载链接

wget https://github.com/vozlt/nginx-module-vts/archive/refs/tags/v0.2.2.zip

3、解压zip包

unzip v0.2.2.zip

4、编译nginx且添加第三方模块

./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-stream=dynamic \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_gunzip_module \
--with-http_flv_module \
--with-http_mp4_module \
--pid-path=/run/nginx.pid \
--lock-path=/run/ningx.lock \
--with-http_geoip_module \
--with-http_auth_request_module \
--with-http_secure_link_module \
--http-log-path=/data/logs/nginx/access.log \
--error-log-path=/data/logs/nginx/error.log \
--with-debug \
--with-stream \
--add-module=/opt/software/nginx-1.22.1/module/nginx-module-vts-0.2.2

注:改成成你刚解压的第三方包路径add-module=/opt/software/nginx-1.22.1/module/nginx-module-vts-0.2.2

make && make install

5、查看是否ok

nginx -V

[root@tmp79 nginx-1.22.1]# nginx -V
nginx version: nginx/1.22.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips ?26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-stream=dynamic --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_flv_module --with-http_mp4_module --pid-path=/run/nginx.pid --lock-path=/run/ningx.lock --with-http_geoip_module --with-http_auth_request_module --with-http_secure_link_module --http-log-path=/data/logs/nginx/access.log --error-log-path=/data/logs/nginx/error.log --with-debug --with-stream --add-module=/opt/software/nginx-1.22.1/module/nginx-module-vts-0.2.2

6、修改nginx配置文件使支持vts

# http里添加一行
http {
    vhost_traffic_status_zone;  #<---添加这里
    include       mime.types;
    default_type  application/octet-stream;
}


# server 里添加一段xNginx_traffic_status

    server {
        listen       6443 ssl;
        server_name  www.hiibm.com;
        ssl_certificate  ../ssl-cert/nginx.crt;
        ssl_certificate_key  ../ssl-cert/nginx.key;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;


       location /xNginx_traffic_status {
           vhost_traffic_status_display;
           vhost_traffic_status_display_format html;
        }
     }

?

7、启动nginx(略)

8、查看vts页面

https://yourdomain/xNginx_traffic_status

文章来源:https://blog.csdn.net/xoofly/article/details/135413319
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。