Search code examples
apachecentos7tomcat9openjdk-11

AJP connection fails


I have two CentOS 7. On one I have Open JDK 11 & Tomcat 9.0.43. The AJP connection setting is like below

    <Connector protocol="AJP/1.3"
           secretRequired="false" 
           address="::1"
           port="8009"
           connectionTimeout="10000"
           keepAliveTimeout="10000"
           redirectPort="8443" />

Added host entry in tomcat server.xml like below

<Host name="ptm" appbase="webapps"
        unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="resumesite_log." suffix=".txt"
                 pattern="common"/> 
        <Context path="/myapp" docBase="/pathtowebapps/webapps/ptm" debug="0" reloadable="true"/>

Firewall is disabled on both servers.

Proxy configuration is like below on apache 2.4

ProxyPass "/myapp" "ajp://<tomcatIP>:8009/myapp"
ProxyPassReverse "/myapp" "http://<tomcatIP>:8080/myapp"

I am able to connect to port 8080 via telnet but on port 8009 I am getting Connection refused.

Tomcat is listening on 8009, checked that with lsof -i -P -n

java       747     root   43u  IPv6 465743      0t0  TCP *:8080 (LISTEN)
java       747     root   49u  IPv6 465747      0t0  TCP [::1]:8009 (LISTEN)
java       747     root   62u  IPv6 466199      0t0  TCP 127.0.0.1:8005 (LISTEN)

java -version

openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9-LTS, mixed mode, sharing)

All ports are open from both machines.

Thanks for your help and support in advance.


Solution

  • Found the solution. Change the address to 0.0.0.0. That will do the trick.

    address="0.0.0.0"

    <Connector protocol="AJP/1.3"
               secretRequired="false" 
               address="0.0.0.0"
               port="8009"
               connectionTimeout="10000"
               keepAliveTimeout="10000"
               redirectPort="8443" />