The log file shared does not appear to include the 502 error result.
This could just be because the error occurred outside the timeframe of the log snippet.
It could also happen if a service like CloudFlare is in front of your droplet and is the source of the 502.
You can view the output of your logs in real-time while testing to help identify exactly the cause and effect around an error.
tail -f /var/log/nginx/error.log
will let you watch for errors
tail -f /var/log/nginx/access.log
will let you watch normal non-error requests in real time.
Ctrl+c will allow you to exit from either of these tail commands.