Nginx 502 Bad Gateway

Nginx About 737 words

现象

请求页面得到502 Bad Gateway

日志

查看error.log日志,发现有upstream sent too big header while reading response header from upstream日志。

2022/10/10 02:18:24 [error] 8333#8333: *28207118 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /test", upstream: "http://example.com", host: "example.com", referrer: "http://test.com/"

原因

请求的Header过大,超出了Nginx代理的缓存区大小。

解决

扩大参数值:proxy_buffer_sizeproxy_buffersproxy_busy_buffers_size

location / {
  proxy_pass       http://upstream;
  ...

  proxy_buffer_size          128k;
  proxy_buffers              4 256k;
  proxy_busy_buffers_size    256k;
}

Nginx 文档

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size

Views: 998 · Posted: 2023-03-13

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh