I recently had a problem while upgrading a Symfony 2.3 project to 2.8. A lot of pages started giving me “502 Bad Gateway” errors for no obvious reason but only when being accessed through ngrok. After some searching and testing I noticed that if I turned off debugging things worked just fine. The dev.log was full of deprecation messages so I fixed a couple of them to make the log more readable. This surprisingly fixed some of the pages.
After even more digging I eventually came across this: https://github.com/Seldaek/monolog/issues/172
After some testing with both Chrome and Firefox I realized that the culprit was ngrok which seems to have a limit on response headers and with all the deprecation messages the application was overflowing that limit. Since my team isn’t using server side debugging with Chrome I disabled the chromephp and firephp log handlers in app/config/config_dev.php and everything started working again.