nginx:[emerg]未知“;字节“u已接收”;变量

nginx:[emerg]未知“;字节“u已接收”;变量,nginx,Nginx,我尝试在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: n

我尝试在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.9
nginx-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
这里有我遗漏的东西吗


谢谢你的帮助

PS:使用答案作为评论,因为我需要发布大文本

似乎是从源代码处编译的,缺少必需的模块。我在同一台计算机上有以下输出

配置参数:--使用cc opt='-g-O2-fPIE-fstack-protector-strong-Wformat-Werror=format security-Wdate time-D_FORTIFY_SOURCE=2'--使用ld opt='-Wl,-b符号函数-fPIE-pie-Wl,-z,relro-Wl,-z,现在'--prefix=/usr/share/nginx--conf path=/etc/nginx/nginx.conf--http log path=/var/log/nginx/access.log--error log path=/var/log/nginx/error.log--lock 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-scgi-temp-path=/var/lib/nginx/scgi--http-uwsgi-temp-path=/var/lib/nginx/uwsgi--with-debug--pcre-jit--with-ipv6--with-http_-ssl_模块--with-http_存根_-status_模块--with-http_realip_模块--with-http_auth_请求_模块--with-http_添加_模块--http_-dav_模块--with-http_-geoip_模块----使用-http_gzip_静态_模块--使用-http_图像_过滤器_模块--使用-http_v2_模块--使用-http_子_模块--使用-http_xslt_模块--使用流--使用流ssl_模块--使用邮件--使用-mail_ssl_模块--使用线程

因此,请确保您至少拥有所有的
模块,并且可能有其他模块是此工作的先决条件

可能是您想要的:

请求长度(包括请求行、标头和请求正文)

如果您使用的是没有内置
ngx\u stream\u core\u模块的Nginx版本,那么它会记录从客户端接收到的请求的大小,而不会出现未知变量问题


换句话说,
$request\u length
(而不是
$bytes\u received
)似乎是
$bytes\u sent
的对应物,有点令人困惑。

什么是
/usr/local/nginx/sbin/nginx-t
?@TarunLalwani:nginx:[emerg]未知的“bytes\u received”变量nginx:configuration file/usr/local/nginx/conf/nginx.conf测试失败这真是奇怪。请同时添加
/usr/local/nginx/sbin/nginx-V
@TarunLalwani的输出,我已将其添加到上述帖子中。谢谢你的帮助!谢谢,我会尝试你的答案并给出反馈!附言:我没有给你否决票。我不明白人们为什么要否决这个答案。无论如何,我投了赞成票来平衡它。干杯