Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2034 closed enhancement (invalid)

Can't log http2 custom header in Nginx access log

Reported by: hijerusalem@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.19.x
Keywords: http2 grpc custom header Cc:
uname -a: Linux GZ_GZJF_VM000317 2.6.32-573.3.1.el6.x86_64 #1 SMP Thu Aug 13 22:55:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.17.8
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.17.8 --with-http_ssl_module --with-http_v2_module --with-http_auth_request_module --with-debug

Description

I want to log gRPC HTTP2 custom header grpc-status in access log
tried

log_format main '$remote_addr - $remote_user [$time_local] "$request"

'$status $http_grpc_status $body_bytes_sent'
'"$http_user_agent" "$http_x_forwarded_for"';

But not working, only http status code logged

Change History (3)

comment:1 by Maxim Dounin, 4 years ago

Resolution: invalid
Status: newclosed

The $http_... variables you are using are for request headers. In contrast, grpc-status is either response header field, or a response trailer field, depending on a particular response. That is, $upstream_http_... or $upstream_trailer_... variables should be used instead.

in reply to:  1 comment:2 by hijerusalem@…, 4 years ago

I used $upstream_trailer_grpc_status,now it's working Thank you Replying to Maxim Dounin:

The $http_... variables you are using are for request headers. In contrast, grpc-status is either response header field, or a response trailer field, depending on a particular response. That is, $upstream_http_... or $upstream_trailer_... variables should be used instead.

in reply to:  1 comment:3 by hijerusalem@…, 4 years ago

If grpc-status is Non-zero it will be a http2 response header, if it's zero it will be a response triler header. In order to log all kinds of grpc-status, I had to specify two fields in log_format: $upstream_http_grpc_status and $upstream_trailer_grpc_status
Is there a way to log grpc-status using just one field, like $status

Replying to Maxim Dounin:

The $http_... variables you are using are for request headers. In contrast, grpc-status is either response header field, or a response trailer field, depending on a particular response. That is, $upstream_http_... or $upstream_trailer_... variables should be used instead.

Version 0, edited 4 years ago by hijerusalem@… (next)
Note: See TracTickets for help on using tickets.