简体   繁体   中英

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 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

I have tried following this by adding the following section to my 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.

Here is the output from /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)

The error is pretty vague - I'm guessing it is something to do with permissions of the /var/log/ directory, maybe?

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 .

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:

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 :

sudo docker ps

And I found out that the docker container was not running anymore.

So all I did was to restart the docker container, and then I checked again and the website was displaying fine.

That's all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM