I aslo had the error with 502 bad gateway. I did some crazy deinstallatzions of PHP and Nginx.
I fixed my error by switching the PHP version for each website to pure static. Then i swapped back to the php version i installed on server. It kinda resetted the website php settings and the site was working excellent again.
Posting here because I was searching so much for a solution maybe s1 will help it 2 🙂
Greetings from Germany best Panel love it ^^