Suppose the requirements are like this: The port that Nginx listens on is 80, and the backend server domain name is assumed to be: http://hello.com, Nginx accepts the request from the client as a proxy, and Nginx forwards the request to http://hello.com. If Nginx and the backend server establish a connection timeout, the data in json format must be returned to the client. The data is assumed to be like this:
{ "code": -1 "message":"failed to connect remote error" }
And I want the client to receive a status code of 500. I would like to ask the seniors to achieve this function, how to configure Nginx?