You should be able to run
tail on the NGINX error log to see what's being logged:
tail -20 /var/log/nginx/error.log
If nothing is being logged to that file, my first guess would be that the Ghost instance is crashing and since NGINX is unable to proxy the request to the Ghost instance (due to it crashing), it throws 502.
If the app is indeed crashing, it'd most likely due to OOM (Out of Memory). This can happen on 512M droplets where resources are far more constrained than they would be on say, a 1GB or 2GB.
If you can post the output of:
That'll give us a better idea of what's being used, cached, etc when it comes to RAM.
You can also use
top to monitor usage. To sort
top, you can use
e which will sort processes by usage, expand the process commands, and show it in human-readable format. Those are keystrokes you'd use after running
Also, for the sake of looking at NGINX's configuration, can you post the contents of: