skip to Main Content

There’s probably something easy I’m missing:

The request hits the apache httpd container-> finds the ajp worker -> finds the worker host on docker network-> tries to send the request to tomcat-> fails saying tomcat container is not listening on port 8009

Docker-compose looks like

version: '2'
  services:
   httpd:

   build:
     context: .
     dockerfile: httpd/Dockerfile
   container_name: "http-proxy"
   volumes:
    - ./httpd/conf/000-default.conf:/etc/apache2/sites-available/000-default.conf
    - ./httpd/conf/workers.properties:/etc/apache2/workers.properties
    - ./httpd/conf/jk.conf:/etc/apache2/mods-available/jk.conf
    - ./httpd/conf/apache2.conf:/etc/apache2/apache2.conf
   ports:
    - 80:80
tomcat:
  image: tomcat:8.5.51
  volumes:
    - ./tomcat/conf/server.xml:/usr/local/tomcat/conf/server.xml
  container_name: "app"
  expose:
   - 8009

workers.properties looks like

worker.app_worker.type=ajp13
worker.app_worker.host=app
worker.app_worker.port=8009

jk.conf has

JkMount /app|/* app_worker

and the connector is available in the tomcat server.xml

  <Connector protocol="AJP/1.3"
           address="::1"
           port="8009"
           redirectPort="8443" />

error

 Failed opening socket to (192.168.164.4:8009) (errno=111)
 [error] ajp_send_request::jk_ajp_common.c (1728): 
 (app_worker) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port

I can confirm tomcat is running.

2

Answers


  1. Using host networking should fix this:

    tomcat:
      network_mode: 'host'
    

    For whatever reason, AJP refused to work with bridge networking for me. And my environment is simpler: it’s a single container with an embedded Tomcat deployed into it. I tested connectivity with an AJP client (https://bz.apache.org/bugzilla/show_bug.cgi?id=47242) and narrowed the issue down to the Tomcat AJP side.

    Login or Signup to reply.
  2. I was having issues with this as well. My docker-compose has Apache and Tomcat containers on a shared bridge network. Instead of using localhost, I set the AJP connector address to 0.0.0.0 in my server.xml. After restarting the Tomcat container I was able to connect to it from my Apache container on 8009.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search