Welcome! Log In Create A New Profile

Advanced

How do I pass through trailing headers

Posted by akc42 
How do I pass through trailing headers
June 07, 2020 04:09AM
I have nginx acting as the static file server for a single page web app I am developing. It acts as a proxy server for the "/api" portion on my url space.

The backend server is running on a different port on local host and is nodejs based.. Im using nginx as an http2 front end and using http 1/1 between nginx and the backend. In the main this is working well.

But I have one problem. I would like to make use of a trailing header. My outgoing request has the header "TE: trailers", and the response has a header "Trailers: API-Status" and then after the body it adds (using nodejs response.addTrailers({'API-Status': 'OK'})).

But nginx is stripping them out.

I can use curl to prove it

curl -b "MBFMVISIT=emailverify; expires=Sun, 07 Jun 2020 13:14:06 GMT;path=/;" -H "Content-Type: application/json" -H "TE: trailers" -X GET -c cookie.jar -i https://footdev.chandlerfamily.org.uk/api/config/config

goes via nginx and outputs the response (including the initial 'Trailers: API-Status' header, but not the trailing header

curl -b "MBFMVISIT=emailverify; expires=Sun, 07 Jun 2020 13:14:06 GMT;path=/;" -H "Content-Type: application/json" -H "TE: trailers" -X GET -c cookie.jar -i http://localhost:2040/api/config/config

goes directly to the backend. in this curl outputs the initial headers, the response and then after the response the trailing header 'API-Status: OK'

My nginx config for the proxy is

location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://localhost:2040;
proxy_redirect default;
proxy_buffering off;
proxy_cache off;
}

So how do I tell nginx to pass the trailing header?



Edited 1 time(s). Last edit at 06/07/2020 04:09AM by akc42.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 229
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready