I got same type issue for 502 Bad Gateway error in Nginx Magento 2
sudo cat /var/log/nginx/error.log
Content as Below:
FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ReflectionException: Class Magento\Framework\App\ResourceConnection\Proxy does not exist in ClassReader.php:26
magento 2 checkout upstream sent too big header while reading response header from upstream, client: server: d request: "POST /customer/account/loginPost/referer/aHR0cDovL2Rldi5lb25iYXphci5jb20vY2hlY2tvdXQv/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.x-fpm.sock:", host: "dev.eonbazar.com", referrer: " /checkout/" ....etc
I solved my issue update my magento nginx config
Replace #Line with below two line
#fastcgi_buffers 1024 4k;
fastcgi_buffers 11024 16k;
fastcgi_buffer_size 32k;