I have astroberry installed and sometime the login via web interface works and then sometimes I get a error message or 502 Bad Gateway error. I can reboot the pi 3b+ and upon reboot I can login in via firefox and sometimes that error returns. I cleared the cache etc to see if that helps. Sometimes it does, sometimes it doesnt
The most probable cause is that graphical environment is not ready for VNC server and upstream Nginx.
In other words you're trying to access desktop with your browser too fast before the desktop fully started and is available to be served to browser.
To trace it down you can connect HDMI cable before boot and check if the problem persists when desktop is ready.
You don't need to reboot when this problem appears, just connect over ssh and run: