While working on a project that involved connecting with LinkedIn’s oauth login this afternoon with a PHP fast-cgi, nginx, rails, passenger setup, I encountered an error that took a bit of trial and error to fix.

upstream sent too big header while reading response header from upstream, client:

I tried following a few people’s advice from various forums and blogs of setting proxy buffer size as shown below and a few other params that didn’t lead me anywhere.

proxy_busy_buffers_size 256k;
proxy_buffers 8 256k;

I started to try everything and finally realized maybe the data that I’m getting back and am trying to store in a session was too large. I had originally had thought the error was from the amount of data LinkedIn was sending back. So instead of doing the below:

session["devise.linked_in_data"] = env["omniauth.auth"]

I simply just only set the data that I really need in the session.