[Solved] Random 502 errors when using nginx

Get this error in the java console, no errors in logs:
POST http://project.elite-star-services.com/invoices/ajax/save 502 (Bad Gateway)

Save Cog / Gear never goes away, but the invoice is actually saved, cannot copy it either when it will not save (if that helps).

Remove the 5th item and all is fine.
running on debian

502 (Bad Gateway)
This is not an issue related to InvoicePlane, it is related to your web server that is not accessible anymore. More: http://wiki-errors.com/502-bad-gateway-error-solutions/

It is not a ‘server problem’, I host about 20 websites across several physical & virtual machines - everything is working fine, it ONLY happens when I add that 5th item to an invoice; with 4 items all is fine - if I delete that 5th item all is fine again. The server would not suddenly become overloaded or unavailable ONLY when I add a 5th item to an invoice, yet all the other sites on that same machine continue to work just fine.

I also migrated that VM to another physical machine, and the problem persists. I will see if I can debug further later on I guess…

Is this an issue related to one special item or does the error pops up on every 5th item no matter what it is?

Every 5th item - tried several names and even took everything out and put very generic names in…
I will provide whatever details you need, but I installed IP on a turnkey linux lamp stack, so it is very generic…

Could you please check these configuration variables, they may be too low:

  • post_max_size
  • max_input_time
  • memory_limit
  • max_input_vars

I have adjusted or added this, then did a restart - same problem…

post_max_size = 64M

max_execution_time = 1000 ; Maximum execution time of each script, in seconds
max_input_time = -1 ; Maximum amount of time each script may spend parsing request data
memory_limit = 1024M ; Maximum amount of memory a script may consume (32MB)
max_input_vars = 10000;

Maybe it is something thing funny with turnkey? Generally I just use those prepackaged VM iso’s for quick tests, then migrate to one of my other hand created stacks - but most are shared, and since IP wants to be root, this worked good (or so I thought).

I also use nginx as a proxy for the server farm, but again, I have 20 other sites using at least 12 different programs / software and everything works great except this.

I can install a new test stack later and see how much hair I pull copying the files and database over…

OK then, so anyone want to share some of this crow with me?
It is too much to eat on my own…

Everything worked when I accessed via the IP address (by-passing the proxy), so clearly the problem was not InvoicePlane or local configuration issues.

The solution turned out to be simple enough, these entries must be added to nginx.conf:
client_max_body_size 128M;
proxy_buffer_size 256k;
proxy_buffers 4 512k;
proxy_busy_buffers_size 512k;

Restart nginx and all is well.

You may want to change the title to something more like ‘random 502 errors when using nginx’ or similar…

Sometimes it’s that simple. :smile: