【问题标题】:Apache Reverse Proxy 503 Service UnavailableApache 反向代理 503 服务不可用
【发布时间】:2021-04-12 02:25:54
【问题描述】:

希望你能帮上忙。我有一个在 Docker 容器 (CentOS 7) 中运行的 apache Web 服务器,它充当运行 JBOSS 的应用程序服务器 (RHEL7.6) 的反向代理 - 这很好用。

我想通过在我的 httpd.conf 中添加一个 ProxyPass 部分来从应用程序服务器公开一些日志文件,就像在反向代理部分中提到的文档一样:https://httpd.apache.org/docs/2.4/urlmapping.html#page-header

我已经尝试通过将以下部分添加到我的 httpd.conf 来遵循这一点

ServerName "${web_server}"
DocumentRoot "/var/www/html"

ProxyRequests Off

RequestHeader set Host "${web_server}:80"

RequestHeader set X-Forwarded-Proto http
ProxyPass "/logs" "http://${app_server}:80/var/log/" retry=0
ProxyPassReverse "/logs" "http://${app_server}:80/var/log/"

# Caching for Proxy Settings
<IfModule mod_mem_cache.c>
    CacheEnable mem /
    MCacheSize 4096
    MCacheMaxObjectCount 100
    MCacheMinObjectSize 1
    MCacheMaxObjectSize 2048
</IfModule>

AcceptFilter https none

使用此配置,我现有的应用程序服务器服务链接可以继续正常工作。但是 /logs 给了我一个 503 Service Unavailable。

这是 /etc/httpd/error.log 的输出

[Wed Jan 06 10:23:32.103107 2021] [proxy:debug] [pid 8:tid 139965551843072] proxy_util.c(2262): [client dockerip:57076] AH00944: connecting http://appserverfqdn/var/log/ to appserverfqdn:80
[Wed Jan 06 10:23:32.103115 2021] [proxy:debug] [pid 8:tid 139965551843072] proxy_util.c(2442): [client dockerip:57076] AH00947: connected /var/log/ to appserverfqdn:80
[Wed Jan 06 10:23:32.104832 2021] [proxy:error] [pid 8:tid 139965551843072] (113)No route to host: AH00957: HTTP: attempt to connect to appserverprivateip:80 (appserverfqdn) failed
[Wed Jan 06 10:23:32.104854 2021] [proxy:error] [pid 8:tid 139965551843072] AH00959: ap_proxy_connect_backend disabling worker for (appserverfqdn) for 0s
[Wed Jan 06 10:23:32.104859 2021] [proxy_http:error] [pid 8:tid 139965551843072] [client dockerip:57076] AH01114: HTTP: failed to make connection to backend: appserverfqdn
[Wed Jan 06 10:23:32.104863 2021] [proxy:debug] [pid 8:tid 139965551843072] proxy_util.c(2224): AH00943: HTTP: has released connection for (appserverfqdn)

这个错误很模糊 - 我猜这可能与 /var/log/ 目录的权限有关?

任何帮助/指导将不胜感激...昨天我为此陷入了困境。

【问题讨论】:

    标签: docker apache logging proxy


    【解决方案1】:

    在使用 Apache2 Web 服务器为在端口 9090 上的 docker 容器中运行的应用程序设置反向代理时,我也有类似的经历。

    当我尝试从终端访问应用程序时,出现以下错误:

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>503 Service Unavailable</title>
    </head><body>
    <h1>Service Unavailable</h1>
    <p>The server is temporarily unable to service your
    request due to maintenance downtime or capacity
    problems. Please try again later.</p>
    <hr>
    <address>Apache/2.4.41 (Ubuntu) Server at mail.verifymenigeria.com Port 443</address>
    </body></html>
    

    这是我修复它的方法

    首先,我检查了 apache2 是否运行良好:

    sudo systemctl status apache2
    

    是的,它运行良好。

    接下来,我检查了 docker 容器是否仍在运行并侦听端口 9090:

    sudo docker ps
    

    我发现 docker 容器不再运行了。

    所以我所做的只是重新启动 docker 容器,然后我再次检查,网站显示正常。

    就是这样

    【讨论】:

      猜你喜欢
      • 2021-07-25
      • 2022-08-15
      • 2019-03-18
      • 2016-10-26
      • 2022-01-21
      • 2019-06-30
      • 1970-01-01
      • 2013-04-02
      • 2015-12-10
      相关资源
      最近更新 更多