[英]Apache Reverse Proxy 503 Service Unavailable
I'm hoping you can help.我希望你能帮忙。 I have an apache web server running in a Docker container (CentOS 7), which acts as a reverse proxy for my application server (RHEL7.6) which is running JBOSS - This works well. I have an apache web server running in a Docker container (CentOS 7), which acts as a reverse proxy for my application server (RHEL7.6) which is running JBOSS - This works well.
I would like to expose some log files from the application server by adding a ProxyPass section in my httpd.conf like the documentation mentions in the Reverse Proxy section: https://httpd.apache.org/docs/2.4/urlmapping.html#page-header我想通过在我的 httpd.conf 中添加一个 ProxyPass 部分来从应用程序服务器公开一些日志文件,如反向代理部分中提到的文档: https://httpd.apache.org/docs/2.4/urlmapping.html#页眉
I have tried following this by adding the following section to my httpd.conf我已经尝试通过将以下部分添加到我的 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
With this configuration my existing links to the application servers services continue to work fine.使用此配置,我与应用程序服务器服务的现有链接继续正常工作。 However /logs gives me a 503 Service Unavailable.但是 /logs 给了我一个 503 服务不可用。
Here is the output from /etc/httpd/error.log这是来自 /etc/httpd/error.log 的 output
[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)
The error is pretty vague - I'm guessing it is something to do with permissions of the /var/log/ directory, maybe?该错误非常模糊 - 我猜这可能与 /var/log/ 目录的权限有关,也许?
Any help/guidance would be appreciated... I was down a large rabbithole with this yesterday.任何帮助/指导将不胜感激......昨天我陷入了一个大兔子洞。
I had a similar experience when setting up a reverse proxy using Apache2 web server for an application running in a docker container on port 9090
.在使用Apache2 web 服务器为在端口9090
上的 docker 容器中运行的应用程序设置反向代理时,我有类似的经历。
When I try to access the application from the terminal I get the error below:当我尝试从终端访问应用程序时,出现以下错误:
<!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>
Here's how I fixed it这是我修复它的方法
First, I checked to see if apache2 is running fine:首先,我检查了 apache2 是否运行良好:
sudo systemctl status apache2
and yes it was running fine.是的,它运行良好。
Next, I checked to see if the docker container was still running and listening on port 9090
:接下来,我检查了 docker 容器是否仍在运行并在端口9090
上侦听:
sudo docker ps
And I found out that the docker container was not running anymore.我发现 docker 容器不再运行。
So all I did was to restart the docker container, and then I checked again and the website was displaying fine.所以我所做的就是重新启动 docker 容器,然后我再次检查,网站显示正常。
That's all就这样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.