Opened 2 weeks ago

Last modified 13 days ago

#2639 new defect

Embedded trailer variables have no value

Reported by: kylesimon3@… Owned by:
Priority: major Milestone:
Component: nginx-module Version: 1.21.x
Keywords: Cc:
uname -a: Linux da1a919cc152 4.15.0-201-generic #212-Ubuntu SMP Mon Nov 28 11:29:59 UTC 2022 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.21.3 (nginx-plus-r25)
built by gcc 8.3.0 (Debian 8.3.0-6)
built with OpenSSL 1.1.1d 10 Sep 2019 (running with OpenSSL 1.1.1n 15 Mar 2022)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --build=nginx-plus-r25 --with-http_auth_jwt_module --with-http_f4f_module --with-http_hls_module --with-http_session_log_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-plus-1.21.3/debian/debuild-base/nginx-plus-1.21.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'


Embedded trailer variables ($sent_trailer_ & $upstream_trailer_) for ngx_http_upstream_module and ngx_http_headers_module do not have any value.

Using the directive:
add_trailer X-TestTrailer $sent_trailer_x_testtrailer
add_trailer X-TestTrailer $upstream_trailer_x_testtrailer

Is not working when the upstream server sends an Http trailer with the name X-TestTrailer.

In testing we've found that add_trailer is working, but the embedded variables do not have values from the upstream response trailers.

Reproducible POC:

Spin up a simple server that serves a trailer in every response. A simple node app like so works just fine:

var http = require('http');
var fs = require('fs');

var server = http.createServer(function(req, res) {
  console.log('request was made: ' + req.url);
  res.writeHead(200, {'Content-Type': 'application/json'});
  res.addTrailers({'X-TestTrailer': 'This is a trailer message'});
  res.end('End of Response');

server.listen(3000, '');
console.log('listening on port 3000');

In the nginx.conf file under your server (should point to the sample app), add:
add_trailer X-TestTrailer $sent_trailer_x_testtrailer;
add_trailer X-UpstreamTestTrailer $upstream_trailer_x_testtrailer;

Start nginx

Make a request directly to the app server ( you can use curl with the --raw argument to see trailers ) note the trailers are received.

Make the same request to the nginx proxy and note the trailers are not received.

Attachments (1)

New Microsoft Access Database (2).accdb (508.0 KB ) - added by tammy annette harrell 2 weeks ago.

Download all attachments as: .zip

Change History (2)

by tammy annette harrell, 2 weeks ago


comment:1 by Roman Arutyunyan, 13 days ago

Only ngx_http_grpc_module / grpc_pass currently supports trailers. If you use proxy_pass, trailers will not work.

Note: See TracTickets for help on using tickets.