When Nginx gets a socket error/timeout from the upstream server, it sends a 502 http error back to the client. I would like to change this default behavior: if Nginx gets a socket error from the upstream, then I'd like it to break the connection towards the client (instead of sending a 502). The reason this is helpful is because some clients know to retry a request when they get a socket error, but they give up when getting the 502. Any ideas how to achieve this?