nginx-module-vts监控虚拟主机的流量

2025-05-25 61 0

nginx-vts

编辑加入模块

git clone https://github.com/vozlt/nginx-module-vts.git
./configure \
    --prefix=/usr/local/openresty \
    --user=www \
    --group=www \
    --with-file-aio \
    --with-poll_module \
    --with-http_realip_module \
    --with-http_image_filter_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_addition_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_slice_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_degradation_module \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_stub_status_module \
    --with-http_slice_module \
    --with-http_geoip_module \
    --with-http_auth_request_module \
    --with-stream \
    --with-stream_ssl_module \
    --with-stream_ssl_preread_module \
    --with-stream_realip_module \
    --with-threads \
    --with-pcre \
    --with-compat \
    --with-stream \
    --with-stream_ssl_module \
    --add-module=./nginx-module-vts
make -j 8 && make install

http {
    # ... 其他http配置
    vhost_traffic_status_zone;
    vhost_traffic_status_filter_by_host on; # If you want to filter by host

    server {
        listen 80;
        server_name 192.168.1.200;

        location /vts_status {
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html; # 或者 prometheus, json
        }

        # ... 其他 server 和 location 配置
    }
}

http://192.168.1.200/vts_status

image.png

http://192.168.1.200/vts_status/format/prometheus

image.png

prometheus

# vim /opt/prometheus/prometheus.yml

  - job_name: 'nginx_vts'
    metrics_path: '/vts_status/format/prometheus'
    static_configs:
      - targets: ['192.168.1.200']
        labels:
          env: 'dev'

Grafana

https://grafana.com/grafana/dashboards/15205-nginx-stats/
image.png

https://grafana.com/grafana/dashboards/14824-nginx-vts-stats/

image.png

https://flashcat.cloud/blog/nginx_vts_scrape/

相关文章

Nginx后端获取CDN用户真实IP
Nginx使用Geoip2模块 解析客户端IP地理信息 限定国家区域访问
Nginx 允许多个域名跨域访问
Nginx上传大文件慢 解决
nginx 1.22 编译webdav插件
ubuntu 22.04 编译 nginx 1.22

发布评论