Full implementation of the nginx dynamic module with: - SO_BINDTODEVICE-based per-interface traffic attribution - Per-worker lock-free counters flushed to shared memory - Prometheus text and JSON scrape endpoint at configurable location - UDP-only global logtail (ipng_stats_logtail) for fire-and-forget access log streaming - $ipng_source_tag nginx variable for use in log_format/map - Histogram buckets, EWMA rate gauges, zone meta-metrics - Debian packaging (libnginx-mod-http-ipng-stats) - Robot Framework end-to-end tests via containerlab - SPDX Apache-2.0 headers on all source files
59 lines
1.6 KiB
Nginx Configuration File
59 lines
1.6 KiB
Nginx Configuration File
# SPDX-License-Identifier: Apache-2.0
|
|
# Test nginx configuration for the ipng_stats module.
|
|
|
|
load_module /usr/lib/nginx/modules/ngx_http_ipng_stats_module.so;
|
|
|
|
error_log stderr notice;
|
|
|
|
events {
|
|
worker_connections 128;
|
|
}
|
|
|
|
http {
|
|
ipng_stats_zone ipng:1m;
|
|
ipng_stats_flush_interval 500ms;
|
|
ipng_stats_default_source direct;
|
|
|
|
log_format tagged '$remote_addr src=$ipng_source_tag vip=$server_addr '
|
|
'"$request" $status $body_bytes_sent';
|
|
access_log /var/log/nginx/access.log tagged;
|
|
|
|
# Global logtail — fires for ALL requests regardless of server block.
|
|
log_format logtail '$host\t$remote_addr\t$ipng_source_tag\t$server_addr\t'
|
|
'$request_method\t$request_uri\t$status\t$body_bytes_sent\t'
|
|
'$request_time';
|
|
ipng_stats_logtail logtail udp://127.0.0.1:9514 buffer=4k flush=500ms;
|
|
|
|
server {
|
|
# Mgmt-only listener for direct traffic (tagged "direct").
|
|
listen 172.20.40.2:8080;
|
|
|
|
# Per-interface listeners for attributed traffic.
|
|
listen 10.0.1.1:8080 device=eth1 ipng_source_tag=cl1;
|
|
listen 10.0.2.1:8080 device=eth2 ipng_source_tag=cl2;
|
|
|
|
server_name _;
|
|
|
|
location / {
|
|
return 200 "ok $server_addr\n";
|
|
}
|
|
|
|
location /notfound {
|
|
return 404 "nope\n";
|
|
}
|
|
|
|
location /slow {
|
|
proxy_pass http://127.0.0.1:29080/;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 172.20.40.2:9113;
|
|
|
|
location = /.well-known/ipng/statsz {
|
|
ipng_stats;
|
|
allow all;
|
|
}
|
|
}
|
|
}
|