如何跟踪在 Nginx 中发送的字节
How to track bytes sent in Nginx
我正在使用 NGinx 作为大型文件内容传送服务器,我需要跟踪在客户端下载文件时发送给客户端的字节数。然后用一些 ID 从他们的帐户中扣除带宽。这是我的 Nginx 配置,但它似乎不起作用。在我的 8899 测试服务器 运行 上,无论如何我都没有受到任何攻击。
location /test {
try_files $uri @afterdownload;
alias /home/ubuntu/test/;
post_action @afterdownload;
}
location @afterdownload {
proxy_pass http://localhost:8899/?FileName=$uri&ClientIP=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion;
internal;
}
你可以使用这个模块
https://github.com/Lax/ngx_http_accounting_module
但我认为您需要进行定制以适应 nginx 之外的情况以及此模块。
我正在使用 NGinx 作为大型文件内容传送服务器,我需要跟踪在客户端下载文件时发送给客户端的字节数。然后用一些 ID 从他们的帐户中扣除带宽。这是我的 Nginx 配置,但它似乎不起作用。在我的 8899 测试服务器 运行 上,无论如何我都没有受到任何攻击。
location /test {
try_files $uri @afterdownload;
alias /home/ubuntu/test/;
post_action @afterdownload;
}
location @afterdownload {
proxy_pass http://localhost:8899/?FileName=$uri&ClientIP=$remote_addr&body_bytes_sent=$body_bytes_sent&status=$request_completion;
internal;
}
你可以使用这个模块 https://github.com/Lax/ngx_http_accounting_module
但我认为您需要进行定制以适应 nginx 之外的情况以及此模块。