skip to Main Content

After upgrading Nginx from 1.18 to 1.24 we are getting following error:

upstream sent duplicate header line: "Transfer-Encoding: chunked", previous value: "Transfer-Encoding: chunked" while reading response header from upstream, client: 54.xx.xx.xx, server: backend.example.com, request: "POST /test/file HTTP/1.1", upstream: "http://10.0.xx.xx:6067/test/file", host: "backend.example.com", referrer: "https://app.example.com/

Nginx version:
nginx/1.24.0

OS Version: Ubuntu 22.04.3 LTS

Configurations:

backend.conf

server {
  access_log /var/log/nginx/access.log;
  index index.html index.htm index.nginx-debian.html;
  server_name backend.example.com;
  include /etc/nginx/http_proxy.conf;
  location /test/file {
    proxy_pass http://10.0.xx.xx:6067/test/file;
    proxy_set_header  X-Real-IP       $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $host;
    proxy_set_header  X-Forwarded-Port 443;
    proxy_set_header  X-Forwarded-Proto https;
    proxy_set_header  X-Forwarded-Host $host:443;
  }
  listen 443 ssl; 
  ssl_certificate /etc/backend.example.com/fullchain.pem; 
  ssl_certificate_key /etc/backend.example.com/privkey.pem; 
  include /etc/options-ssl-nginx.conf; 
  ssl_dhparam /etc/ssl-dhparams.pem;
}

http_proxy.conf

proxy_buffers           32 4k;
proxy_http_version      1.1;
proxy_send_timeout      60;
proxy_read_timeout      60;
proxy_connect_timeout   60;
proxy_set_header    Connection    '';

The request is successfully processed at the backend(spring-boot) but we are getting above error in error.log of backend Nginx which makes frontend fail with 502

If we remove include /etc/nginx/http_proxy.conf; from server block
We are getting following error:

upstream sent invalid chunked response while reading upstream, client: 54.xx.xx.xx,server: backend.example.com, request: "POST /test/file HTTP/1.1”, upstream: "http://10.0.xx.xx:6067/test/file", host: "backend.example.com”, referrer: "https://app.example.com/

Let me know if some other details are required.

Any help or direction to solve this issue is appreciated.
Thanks in advance.

2

Answers


  1. Couple days ago I got the same error after upgrading Nginx from 1.18.0 to 1.24.0. I tried too many paramteres.

    You should try to add this "chunked_transfer_encoding off" parameter in your nginx.conf. This one fixed my problem.

    sendfile        on;
    server_tokens off;
    keepalive_timeout  65;
    chunked_transfer_encoding off;
    include /etc/nginx/conf.d/*.conf;
    
    Login or Signup to reply.
  2. To resolve the error that many people encounter after upgrading Nginx, you can directly add the "chunked_transfer_encoding off;" parameter to the configuration file (nginx.conf) in the Nginx directory (/etc/nginx/nginx.conf).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search