首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Apache服务器反向代理另一个apache服务器,获取"AH01102:从远程服务器读取状态行错误“

Apache服务器反向代理另一个apache服务器,获取"AH01102:从远程服务器读取状态行错误“
EN

Stack Overflow用户
提问于 2020-07-11 20:56:12
回答 2查看 23.3K关注 0票数 8

我在两台独立的物理机器上安装了两个apache服务器。我目前的设置是:

代码语言:javascript
运行
复制
                      Apache 1 (Reverse Proxy) <===> Apache 2

两个apache服务器版本都是运行在Apache/2.4.29 (Ubuntu)上的Ubuntu 18.04.4 LTS,它们的/etc/apache2/apache.conf文件是相同的。

Apache 1站点-启用配置:

代码语言:javascript
运行
复制
<VirtualHost *:80>
        ServerName subdomain.domain.tld
        ServerAlias www.subdomain.domain.tld

        ServerAdmin webmaster@domain.tld
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        ProxyRequests off
        ProxyPreserveHost On
        ProxyPass /maintenance_page !
        ProxyPass / http://[apache2-ip-address]:27300/ 
        ProxyPassReverse / http://[apache2-ip-address]:27300/
</VirtualHost>

Apache 2站点-启用配置:

代码语言:javascript
运行
复制
<VirtualHost *:27300>
        ServerName subdomain.domain.tld
        ServerAlias www.subdomain.domain.tld

        ServerAdmin webmaster@domain.tld
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ErrorDocument 400 /notfound.html

        ProxyRequests off
        ProxyPreserveHost on
</VirtualHost>

如果我直接从web浏览器点击http://[apache2-ip-address]:27300/,apache服务器登陆页面就会显示得很好。如果在浏览器中输入http://subdomain.domain.tld,就会得到一个代理错误:

代码语言:javascript
运行
复制
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request

我在两个apache服务器上都记录了一个跟踪。Apache服务器2正在接收来自apache服务器1的代理请求,并向apache服务器1返回200状态响应。在apache服务器1处,流中断,我看到以下日志:

代码语言:javascript
运行
复制
[Sat Jul 11 20:34:08.671267 2020] [proxy:debug] [pid 32275:tid 140388069250816] proxy_util.c(3075): AH00962: HTTP: connection complete to [apache2-ip-address]:27300 ([apache2-ip-address])
[Sat Jul 11 20:34:08.671333 2020] [core:trace6] [pid 32275:tid 140388069250816] core_filters.c(525): [remote [apache2-ip-address]:27300] core_output_filter: flushing because of FLUSH bucket
[Sat Jul 11 20:34:08.677508 2020] [proxy_http:error] [pid 32275:tid 140388069250816] (104)Connection reset by peer: [client xx.xxx.xxx.xx:39014] AH01102: error reading status line from remote server [apache2-ip-address]:27300
[Sat Jul 11 20:34:08.677575 2020] [proxy_http:debug] [pid 32275:tid 140388069250816] mod_proxy_http.c(1324): [client xx.xxx.xxx.xx:39014] AH01105: NOT Closing connection to client although reading from backend server [apache2-ip-address]:27300 failed.
[Sat Jul 11 20:34:08.677624 2020] [proxy:error] [pid 32275:tid 140388069250816] [client xx.xxx.xxx.xx:39014] AH00898: Error reading from remote server returned by /
[Sat Jul 11 20:34:08.677681 2020] [proxy:debug] [pid 32275:tid 140388069250816] proxy_util.c(2192): AH00943: HTTP: has released connection for ([apache2-ip-address])
[Sat Jul 11 20:34:08.677724 2020] [http:trace3] [pid 32275:tid 140388069250816] http_filters.c(1128): [client xx.xxx.xxx.xx:39014] Response sent with status 502, headers:

我尝试过的一些东西,从我可以在网上找到的其他几个讨论,是对apache服务器1站点的以下修改--启用配置:

  1. SetEnv proxy-initial-not-pooled 1
  2. SetEnv force-proxy-request-1.0 1
  3. SetEnv proxy-nokeepalive 1
  4. ProxyTimeout 600
  5. ProxyPass / http://[apache2-ip-address]:27300/ timeout=600
  6. ProxyPass / http://[apache2-ip-address]:27300/ nocanon

我对上述设置的几种组合进行了很强的暴力处理,但似乎没有什么效果。任何帮助都是非常感谢的。

我运行的另一项检查是,如果我在与apache相同的机器上运行nodejs应用程序或python服务,并使用ProxyPass / http://localhost:[port]/代理服务,则设置工作正常。因此,两个apache服务器都运行良好,并且能够在各自的本地主机上代理服务。不管是什么中断,都与两个apache服务器之间的通信有关。

UPDATE :使用curl对网络用户进行进一步的分类时,问题似乎是组织防火墙只允许入站流量到apache 2,并阻塞出站流量,这可能会在apache 1上造成502个错误。直到我意识到我的膝上型计算机一直被VPN接入组织网络,并且apache服务器1一直处于组织网络之外,这似乎并不是一个问题。如果这是一个问题,那将是一个真正的令人沮丧的问题。

EN

回答 2

Stack Overflow用户

发布于 2020-10-15 06:10:51

在http.conf文件中添加以下参数解决了我的“代理:从远程服务器读取状态行错误”的问题:

代码语言:javascript
运行
复制
SetEnv proxy-initial-not-pooled 1

我从Apache https://httpd.apache.org/docs/2.4/mod/mod_proxy_http.html中获取引用

注意:重新启动http服务器,然后重试。

票数 4
EN

Stack Overflow用户

发布于 2020-12-22 14:50:42

在我的例子中,数据库连接的一个错误触发了Apache的反向Proxyng错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62854501

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档