Return 5xx when upstream is unreachable

Currently a 404 is returned for a misconfigured or unavailable upstream
server.  Since that's a server error it should be a 5xx instead; a 404
is confusing when used as a forward proxy and might even be harmful when
used as a reverse proxy.

It is debatable if another 5xx code might be better; the misconfigured
situation might better be a 500 whereas the connection issue could be
a 503 instead (as used eg. in haproxy).
This commit is contained in:
Malte S. Stretz authored and rofl0r committed 2022-02-13 21:46:03 +00:00
1 parent eced6822f8
commit 1576ee279f
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -1424,7 +1424,7 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
log_message (LOG_WARNING,
"No upstream proxy defined for %s.",
request->host);
indicate_http_error (connptr, 404,
indicate_http_error (connptr, 502,
"Unable to connect to upstream proxy.");
return -1;
}
@@ -1436,7 +1436,7 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
if (connptr->server_fd < 0) {
log_message (LOG_WARNING,
"Could not connect to upstream proxy.");
indicate_http_error (connptr, 404,
indicate_http_error (connptr, 502,
"Unable to connect to upstream proxy",
"detail",
"A network error occurred while trying to "