0

On my previous server I had a perfectly functioning Apache 2.2 Configuration.

On one hand this said perfectly functioning Apache 2.2 config has the purpose of acting as a Load-Balancer for a Web-Application running on different Tomcats.

After migrating to Apache 2.4 the Load Balancing part of the config is still intact and functioning properly.

However on the other hand after switching versions the ProxyPass/ProxyPassReverse configuration does not work the way it used to.

This is how the perfectly fine working ProxyPass/ProxyPassReverse configuration looked like in Apache 2.2:

<VirtualHost *:443>
        ServerName mysubdomain.xyz.com
        ProxyRequests Off
        ...
        <Location /manager_myhostname1>
             Order deny,allow
             Deny from all
             Allow from 12.34.56.78
             ProxyPass ajp://myhostname1:8009/manager route=myhostname1
             ProxyPassReverse ajp://myhostname1:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname1
        </Location>
        <Location /manager_myhostname2>
             Order deny,allow
             Deny from all
             Allow from 12.34.56.78
             ProxyPass ajp://myhostname2:8009/manager route=myhostname2
             ProxyPassReverse ajp://myhostname2:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname2
        </Location>
        <Location /manager_myhostname3>
             Order deny,allow
             Deny from all
             Allow from 12.34.56.78
             ProxyPass ajp://myhostname3:8009/manager route=myhostname3
             ProxyPassReverse ajp://myhostname3:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname3
        </Location>
</VirtualHost>

The above part of the config basically facilitates that the Tomcat Manager Pages of the individual hosts of the Load-Balancing-Cluster are accessible through these URLs:

- mysubdomain.xyz.com/manager_myhostname1
- mysubdomain.xyz.com/manager_myhostname2
- mysubdomain.xyz.com/manager_myhostname3

To rule out common errors while migrating from Apache 2.2 to 2.4 I have rewritten the above config like this:

<VirtualHost *:443>
        ServerName mysubdomain.xyz.com
        ProxyRequests Off
        ...
        <Location /manager_myhostname1>
             Require ip 12.34.56.78
             ProxyPass ajp://myhostname1:8009/manager route=myhostname1
             ProxyPassReverse ajp://myhostname1:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname1
        </Location>
        <Location /manager_myhostname2>
             Require ip 12.34.56.78
             ProxyPass ajp://myhostname2:8009/manager route=myhostname2
             ProxyPassReverse ajp://myhostname2:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname2
        </Location>
        <Location /manager_myhostname3>
             Require ip 12.34.56.78
             ProxyPass ajp://myhostname3:8009/manager route=myhostname3
             ProxyPassReverse ajp://myhostname3:8009/manager
             SetOutputFilter proxy-html
             ProxyHTMLURLMap /manager /manager_myhostname3
        </Location>
</VirtualHost>

But these changes were of no avail. When accessing the URL mysubdomain.xyz.com/manager_myhostname1 the Apache gives me the following error page:

<html>
    <head>
        <title>404 Not Found</title>
    </head>
    <body>
        <h1>Not Found</h1>
        <p>The requested URL /manager/ was not found on this server.</p>
        <hr>
        <address>Apache/2.4.25 (Debian) Server at mysubdomain.xyz.com Port 443</address>
    </body>
</html>

The same error takes place for the other two URLs.

It seems that no matter which part after the first forward slash comes in, it gets rewritten into /manager instead of /manager_myhostname1 (or analogously /manager_myhostname2, /manager_myhostname3).

  1. Which crucial part have I missed during the migration?
  2. Are there any obvious misconfigurations in the above config?
  3. Why is the ProxyPass/ProxyPassReverse configuration not working anymore, so that I can access the Tomcat manager pages of the individual tomcat hosts referenced by /manager_myhostname1 etc. like I could on Apache 2.2?

EDIT:

I have already searched through these sources and tried different things out:


EDIT for @Gerald Schneider first comment:

I apologize for not using a CLI tool to do the request:

myuser@myhomecomputer ~ $ wget -S https://mysubdomain.xyz.com/manager_myhostname1
--2019-05-14 15:59:27--  https://mysubdomain.xyz.com/manager_myhostname1
Resolving mysubdomain.xyz.com (mysubdomain.xyz.com)... 57.5.103.87
Connecting to mysubdomain.xyz.com (mysubdomain.xyz.com)|57.5.103.87|:443... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Date: Tue, 14 May 2019 13:59:27 GMT
  Server: Apache-Coyote/1.1
  Location: /manager/
  Content-Length: 0
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
Location: /manager/ [following]
--2019-05-14 15:59:27--  https://mysubdomain.xyz.com/manager/
Reusing existing connection to mysubdomain.xyz.com:443.
HTTP request sent, awaiting response... 
  HTTP/1.1 404 Not Found
  Date: Tue, 14 May 2019 13:59:27 GMT
  Server: Apache/2.4.25 (Debian)
  Content-Length: 283
  Keep-Alive: timeout=5, max=99
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
2019-05-14 15:59:27 ERROR 404: Not Found.

EDIT for @Gerald Schneider second comment:

I have added ProxyHTMLEnable On, but it has no effect whatsoever, as the ouptut of the wget is exactly as above.


EDIT after activating logging for the proxy_html module, which is responsible for the mapping of proxied urls. The log now contains the following lines:

[Wed May 15 10:35:01.671633 2019] [proxy:debug] [pid 26190] proxy_util.c(2418): [client 12.34.567.890:60476] AH00947: connected /manager to myhostname1:8009
[Wed May 15 10:35:01.672047 2019] [proxy:debug] [pid 26190] proxy_util.c(2884): AH02824: HTTP: connection established with 192.168.0.3:8009 (myhostname1)
[Wed May 15 10:35:01.672083 2019] [proxy:debug] [pid 26190] proxy_util.c(3051): AH00962: HTTP: connection complete to 192.168.0.3:8009 (myhostname1)
[Wed May 15 10:35:01.673241 2019] [proxy_http:trace3] [pid 26190] mod_proxy_http.c(1376): [client 12.34.567.890:60476] Status from backend: 302
[Wed May 15 10:35:01.673319 2019] [proxy_http:trace3] [pid 26190] mod_proxy_http.c(1647): [client 12.34.567.890:60476] start body send
[Wed May 15 10:35:01.673339 2019] [proxy:debug] [pid 26190] proxy_util.c(2171): AH00943: http: has released connection for (myhostname1)
[Wed May 15 10:35:01.673351 2019] [proxy_html:trace1] [pid 26190] mod_proxy_html.c(827): [client 12.34.567.890:60476] No content-type; bailing out of proxy-html filter

The connection to the proxied server seems successful, but the last line says No content-type; bailing out of proxy-html filter, indicating that any Directives from the proxy_html module are not applied.

  • Can you please try to run the request with wget or curl and post the output including headers (for example wget -S https://mysubdomain.xyz.com/manager_myhostname1? I have the suspicion that your backend server serves a redirect, since they are configured as /manager and that's where you end. – Gerald Schneider May 14 at 13:57
  • Do you have ProxyHTMLEnable On somewhere in your config? It's off by default. – Gerald Schneider May 14 at 14:06
0

I changed my configuration to this:

<Location /manager_myhostname1>
    Require ip 12.34.56.78
    ProxyPass ajp://myhostname1:8009/manager route=myhostname1
    ProxyPassReverse ajp://myhostname1:8009/manager
    SetOutputFilter proxy-html
    ProxyHTMLURLMap /manager/ /manager_myhostname1/
</Location>

Differences are the ending slashes in the ProxyHTMLURLMap. (analogously for manager_myhostname2 and manager_myhostname3)

Now I can access the individual manager pages with these URLs:

Seems like the proxying gets destroyed when Apache gets the redirect from the /manager page to the /manager/html page. That redirect is something that Tomcat does internally, but can't communicate to the Apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.