我有一个Apache设置为反向代理。 当上游服务有错误(例如500)时,错误不会返回给客户端,而是apache提供502“从远程服务器读取错误”。
我想将原始错误返回给客户端。
注意,当上游服务正常工作(200 OK),然后Apache返回预期的响应。 500回应被掩盖。
直接调用上游服务返回正确的500响应和内容没有问题。
这就是我们现在所拥有的:
ProxyPass "/path" "http://host:port/path" ProxyPassReverse "/path" "http://host:port/path"
而服务返回500时的回应
Bad Gateway! The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /path/to/resource. Reason: Error reading from remote server If you think this is a server error, please contact the webmaster. Error 502 publichostname Apache/2.4.6 (Linux/SUSE)
是否有一些Apacheconfiguration更改,将使Apache转发原始响应,无论状态码?
您至less需要安装2.4.16。
此行为是您使用的版本中的一个错误,在2.4.13(未发布)
*)mod_proxy:除非failonstatusconfiguration为false,否则不要将worker设置为错误状态,以避免由后端返回的500或503错误。 PR 56925. [Yann Ylavic]