I'm running nginx, Phusion Passenger and Rails.
I am running up against the following error:
upstream sent too big header while reading response header from upstream, client: 87.194.2.18, server: xyz.com, request: "POST /user_session HTTP/1.1", upstream: "passenger://unix:/tmp/passenger.3322/master/helper_server.sock
It is occuring on the callback from an authentication call to Facebook Connect.
After googling, and trying to change nginx settings including proxy_buffer_size and large_client_header_buffers is having no effect.
How can I debug this?
Try to add this to the config:
I thought I'd chime in with my solution since I don't see it currently listed. Turns out I was unintentionally putting a large object into the session, as shown below.
This only happened when somebody first authenticated with GitHub OAuth and subsequently tried to authenticate with another social profile that used the same email (why I couldn't originally figure out the issue).
Here's the full
OmniauthCallbacksController
for contextual reference:All was well once I removed the offending line. I am guessing I had it in there for debugging purposes.
Came across this error recently.
Since Passenger 3.0.8 there is now a setting that allows you to set the buffers and buffer size. So now you can do
That resolved the issue for me.
Maybee adding this will make it work, how are you connecting to upstream? http, fastcgi or something else?
This is everything I have come to understand about this error in the last 2 years:
upstream sent too big header while reading response header from upstream
is nginx's generic way of saying "I don't like what I'm seeing"3: Look at the error logs above the message, is it streaming with logged lines preceding the message?
PHP message: PHP Notice: Undefined index:
Example snippet from a loop my log file:you can see in the 3rd line (from the 20 previous errors) the buffer limit was hit, broke, and the next thread wrote in over it. Nginx then closed the connection and returned 502 to the client.
2: log all the headers sent per request, review them and make sure they conform to standards (nginx does not permit anything older than 24 hours to delete/expire a cookie, sending invalid content length because error messages were buffered before the content counted...)
examples include:
and this:
1: verify, or make a script log, to ensure your thread is reaching the correct end point and not exiting before completion.