502 bad gateway is the error that nginx returns when NodeBB isn't running. Try running NodeBB will ./nodebb slog or ./nodebb dev and look for errors. Odds are that it is encountering an error and dying.
@dev Post your config you are using for nginx and config.json. It should be obvious when we can see them.