Right now we are writing a gateway server, it receives a request from client, modify it and send the modified request to upstream, then copy response back to client.
Here we come out a problem that, what if upstream returns HTTP status code 500, should we return 500 to client? If so, how do we distinguish whether gateway failed or upstream failed?
Similar issues also apply to HTTP status code 404, 429 etc...
So, question is:
1. Should gateway return HTTP status code as whatever upstream returns?
In this case, how do we distinguish which server failed exactly
(consider that in a monitor system)
2. Is it a good practice that gateway map upstream status codes to some
fixed range of status codes? e.g. upstream 5xx -> client 502