Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#123 closed defect (invalid)

log_format doesn't allow logging of HTTP headers with a dash

Reported by: pepello - Owned by: somebody
Priority: major Milestone:
Component: nginx-core Version: 1.1.x
Keywords: log_format sent_http dash Cc:
uname -a: Linux desa3 2.6.18-274.17.1.el5.centos.plusxen #1 SMP Wed Jan 11 11:44:32 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.0.12
configure arguments: --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_stub_status_module --with-file-aio --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Description

Hi,

I've hit a bug in this awesome software. I'm trying to log some headers that our upstream generates, their name have a dash '-' in the middle, but log_format directive ignores all after the first dash in '$sent_http_'.

When you set a log format like this (trying to log Content-Length header, but any header-with-a-dash):

log_format lenght '"$sent_http_Content-Length"';

This is logged:

"--Length"

This is reproducible with all the versions available: 1.0.13, 1.1.16 and 0.8.55, too sorry I'm not able to fix it :-(

Thanks!

Change History (2)

comment:1 by Valentin V. Bartenev, 13 years ago

Resolution: invalid
Status: newclosed

The header name in $sent_http_* variables must be lowercase and with dashes (-) replaced by underscores (_). For example, in your case: $sent_http_content_length.

You can found some examples in the documentation, but looks like that this rule needs to be documented explicitly.

comment:2 by pepello -, 13 years ago

Ok, that way works perfectly. Doc should be updated though.

Thanks!

Note: See TracTickets for help on using tickets.