Nginx Proxies with FirePHP

16 Jun

FirePHP_Large_WhiteFirePHP is a great plugin for php+ajax devs — in essence, it captures error and logging output and sends it over HTML headers instead of the content body. These logs show up in your firebug console alongside your javascript logs, making it great for ajax development. You want your output clean but your error and logging info accessible, and lets face it, tail -f is just not as sexy as firebug.

If you’re running your development environment behind an nginx proxy, you may run into some 502 Bad Gateway errors after enabling FirePHP.

[error] 103#0: *839 upstream sent too big header while reading response header from upstream

This happens because FirePHP’s output can get pretty large, and nginx by default tries to cap header output. The fix is simple, in your nginx.conf simply add the following lines:


proxy_buffer_size 16k;
proxy_buffers 4 16k;

You can bump up the header size (the last parameter) to whatever is required by your app to stop throwing errors.

  • Hi, FYI this can also happen if you're not using nginx as a proxy but as a regular httpd, using fastcgi for PHP. The fix is very similar - just add these lines to your nginx config file and adjust the sizes as necessary:

    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
  • nlsmith
    Your last article talked about server-side js, you can use firephp on that, too: http://nlsmith.com/projects/console/ (and rails: http://github.com/smith/firephp_rails/tree/master)

    I ran into the same type of bug on Jaxer and to a lesser degree, ASP.

    I'm planning on making it Jack middleware, too.
  • And yes, I think Jack support is a great move for the project -- I think it'll find more adoption on Jack than Jaxer. Nothing wrong with Jaxer, but I have a feeling that Jack will be widely adopted going forward just because of it's WSGI/Rack approach.
  • Very cool project you put together! I will definitely give it a try -- I'm finding that I can't live without FirePHP now. I'm sure that will carry over to my server-side JS projects and this sounds like the perfect solution. Cheers!
blog comments powered by Disqus