Yesterday I was configuring WordPress and Jetpack when I got a 502 Bad Gateway error error from Nginx.
It’s simple enough to fix but I’ve not used Nginx too much, here’s the problem and solution…
When you’re using Nginx as a reverse proxy to Apache sometimes the upstream server can send headers too big to fit in the Nginx buffer. We’re using Plesk Control Panel on our server, so I’m not sure if it’s to do with the defaults set for Nginx within that but to fix it do the following.
Open /etc/nginx/nginx.conf in your favourite editor
Add the following inside the http directive:
proxy_buffers 8 32k;
Save it, restart Nginx and Apache, ta da!
Your mileage may vary so play about with the number of buffers and their sizes.