Apache 作为代理产生故障。

Hyt*_*ham 4 mod-proxy apache-2.2

我们正在使用 apache 代理来使我们的应用程序服务器能够通过 Internet 访问特定的网站。设置如下:

application servers --> apache proxy --> Internet website 
Run Code Online (Sandbox Code Playgroud)

一些请求失败并在应用程序服务器日志中出现以下错误:

<head>
<title>502 Proxy Error</title>
</head><body>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request <em><a href="/link">POST
nbsp;/link</a></em>.<p>
Reason: <strong>Error reading from remote server</strong></p></p>
</body>
Run Code Online (Sandbox Code Playgroud)

以及 apache error.log 文件中的以下调试日志:

[Mon May 20 09:57:54 2013] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //myURL.com
[Mon May 20 09:57:54 2013] [debug] proxy_util.c(1506): [client 172.20.101.71] proxy: https: found worker `https://myurl.com/` for `https://myurl.com/link`
[Mon May 20 09:57:54 2013] [debug] mod_proxy.c(1015): Running scheme https handler (attempt 0)
[Mon May 20 09:57:54 2013] [debug] mod_proxy_http.c(1973): proxy: HTTP: serving URL https://myurl.com/link
[Mon May 20 09:57:54 2013] [debug] proxy_util.c(2011): proxy: HTTPS: has acquired connection for (mu=y url)
[Mon May 20 09:57:54 2013] [debug] ssl_engine_io.c(1908): OpenSSL: I/O error, 5 bytes expected to read on BIO#136e90 [mem: 190593]
[Mon May 20 09:57:54 2013] [debug] proxy_util.c(2067): proxy: connecting https://myurl.com/link to myurl.com:443
[Mon May 20 09:57:54 2013] [debug] proxy_util.c(2193): proxy: connected /link to myurl.com:443
[Mon May 20 09:57:54 2013] [debug] ssl_engine_io.c(1908): OpenSSL: I/O error, 5 bytes expected to read on BIO#136e90 [mem: 190593]
[Mon May 20 09:57:54 2013] [info] [client ip] (131)Connection reset by peer: SSL input filter read failed.
[Mon May 20 09:57:54 2013] [error] [client ip2] (131)Connection reset by peer: proxy: error reading status line from remote server myurl.com:443
[Mon May 20 09:57:54 2013] [debug] mod_proxy_http.c(1466): [client ip2] proxy: NOT Closing connection to client although reading from backend server "myurl.com:443 failed.
[Mon May 20 09:57:54 2013] [error] [client ip2] proxy: Error reading from remote server returned by /link
[Mon May 20 09:57:54 2013] [debug] proxy_util.c(2029): proxy: HTTPS: has released connection for (myurl.com)
Run Code Online (Sandbox Code Playgroud)

我知道如何解决这个问题的任何想法,知道大多数请求已成功发送并且响应正在正常接收。所有请求的长度相同并自动生成,因此问题不可能出在请求本身。

mas*_*oeh 5

看起来这个Apache Bugzilla 中描述了一些问题。该溶液被添加在这些线httpd.conf的内部<Proxy>部分

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
Run Code Online (Sandbox Code Playgroud)

更新

部署上述解决方案后,我遇到了另一个问题,因为客户端使用 HTTP/1.1 发送请求,并且代理根据之前的 setEnv 参数被迫使用 HTTP/1.0,这导致 HTTP 错误HTTP/1.1 417 Expectation FailedSO上的这个线程提到可以从客户端或代理端解决错误。

最后,我基于这个页面在代理端实现了解决方案。现在我在<Proxy>Section 中有三个参数

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
RequestHeader unset Expect early
Run Code Online (Sandbox Code Playgroud)

从昨天开始,我一直在监视解决方案,直到现在它都运行良好。此外,我昨天对 500 笔交易进行了测试,它们都成功了。

更新 2

从那时起,它已被添加到 Apache 文档中