NGINX gives 502 upstream sent too big header while reading response header from upstream, How to find out what the origin of the issue is?

Viewed 7722

As described in the title, NGINX gives me an upstream sent to big header error in the error logs.

2017/09/20 13:30:10 [error] 23665#23665: *100918355 upstream sent too big header while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.xxx.xxx.com, request: "POST /media_plans HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:xxxx/media_plans", host: "xxx.xxx.com", referrer: "https://xxx.xxx.com/advertisers/4/dealers"

I found a few other posts and blogs telling me to increase the buffer size like this,

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

Now i do not mind changing the config of nginx it seems that it doesn't solve the issue and i actually want to know what is causing it instead of just increasing buffer sizes.

If i am understanding it correct the command below shows me the average size of the headers and the maximum size of them.

awk '($9 ~ /200/) { i++;sum+=$10;max=$10>max?$10:max; } END { printf("Maximum: %d\nAverage: %d\n",max,i?sum/i:0); }' access.log
Maximum: 1236947
Average: 1529

A maximum of 1.23 mb has starting me to wonder that maybe something else is wrong. I'd rather fix the origin of the issue than to increase buffer sizes.

How can i find out what the size of the headers is within rails?

0 Answers
Related