我尝试在Nginx中记录从客户端接收的字节数,如下所示:
log_format postdata '$remote_addr sent $bytes_received bytes';但是,在尝试启动服务时会出现以下错误:
nginx: [emerg] unknown "bytes_received" variable据我所见,这个变量应该出现在Nginx1.11.4中。我跑1.13.9:
#:/usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.9nginx -V输出:
:~# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.13.9
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-pcre --with-http_realip_module --with-stream --add-module=../nchan这里有什么东西我遗漏了吗?
谢谢你的帮助!
发布于 2018-04-03 18:43:03
PS:使用答案作为注释,因为我需要发布大文本
似乎您已经从源代码编译了它,并且缺少了所需的模块。在相同的情况下,我的输出低于
配置参数:现在前缀=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf -http-log-path=/var/log/nginx/access.log.log-log-path=/var/log/nginx/error.log-path=/var/lock/nginx.lock-pid-path=/run/nginx.pid- --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy -http-scgi-temp-path=/var/lib/nginx/scgi-http-uwsgi-temp-path=/var/lib/nginx/uwsgi-with-调试-with-pcre-jit-with-http_ssl_module with-http_stub_status_module-具有-http_auth_realip_module with-http_auth_request_module with 6http_dav_module --具有-http_geoip_模块-带有-http_gzip_static_模块--带有-http_gzip_static_模块-带有-http_v2_模块-带有-http_sub_模块-带有-http_xslt_模块-具有流_ssl_模块-具有-邮件-带有-mail_ssl_模块-带线程-
因此,至少要确保您拥有所有的stream模块,并且可能是其他模块,这是工作的先决条件。
发布于 2021-05-19 17:44:52
$request_length可能是您想要的:
请求长度(包括请求行、标头和请求正文)
这将记录从客户端收到的请求的大小,而不会碰到未知的变量问题,如果您使用的是Nginx的构建,而Nginx没有内置ngx_stream_core_module。
换句话说,$request_length (而不是$bytes_received)似乎是$bytes_sent的对应物,有点令人困惑。
https://stackoverflow.com/questions/49628582
复制相似问题