Nginx从1.18升级到1.24后,出现以下错误:
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版本:**nginx/1.24.0
**操作系统版本:**Ubuntu 22.04.3 LTS
密码:
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 '';
请求在后端(spring-boot)成功处理,但我们在后端Nginx的error.log中获得了上述错误,这使得前端失败,并显示502
如果我们删除 include /etc/nginx/http_proxy.conf; 从服务器块我们得到以下错误:
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/
如果需要其他细节,请告诉我。
任何帮助或指导,以解决这个问题是赞赏。先谢了。
2条答案
按热度按时间4ioopgfo1#
要解决很多人升级Nginx后遇到的错误,可以直接添加“chunked_transfer_encoding off;”参数添加到Nginx目录(/etc/nginx/nginx.conf)中的配置文件(nginx. conf)。
bcs8qyzn2#
几天前,我在将Nginx从1.18.0升级到1.24.0后遇到了同样的错误。我尝试了太多的参数。
您应该尝试在nginx. conf中添加此“chunked_transfer_encoding off”参数。这个解决了我的问题。