Apache反向代理503服务不可用

xxls0lw8  于 2022-11-16  发布在  Apache
关注(0)|答案(1)|浏览(409)

我有一个在Docker容器(CentOS 7)中运行的apache Web服务器,它作为我的应用服务器(RHEL7.6)的反向代理,运行JBOSS -这工作得很好。
我希望通过在httpd.conf中添加ProxyPass部分来公开应用服务器中的一些日志文件,就像文档中的ReverseProxy部分所提到的那样: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服务不可用。
下面是来自/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/目录的权限有关?
任何帮助/指导都将不胜感激...我昨天被这个弄倒了一个大兔子洞。

ncecgwcz

ncecgwcz1#

我在使用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容器,然后我再次检查,网站显示正常。

相关问题