Docker – Cannot Access Tomcat Servlet Using HTTPD AJP Proxy

ajpapache-2.4dockermod-proxytomcat

Docker, httpd and tomcat is new to me.

What I want to do: Access tomcat servlet through httpd ajp reverse proxy.

I am making two containers under same bridge network, one runs httpd, another tomcat.

Problem: I can not access tomcat through httpd. Httpd returns 403 error. I can access through port 8080 if I expose it to the host. I have read many articles but do not understand what I am doing wrong. Current configuration should work according to my understanding but surely I am missing something.

Screenshot of error page

Kindly give me pointers what am I doing wrong.

My configurations and dockerfiles
Please see the Git repository here.
I run the container by first creating image and run by following

# Start web container
docker run -dit --name httpd.container -p 80:80 --network extope-network httpd-101-image
# Start AP container
docker run -dit --name tomcat.container -p 8080:8080 --network extope-network --add-host=host.docker.internal:host-gateway tomcat-101-image

Best Answer

Remove the quotes from the secret in your httpd config.

ProxyPass "/docs" "ajp://tomcat.container:8009/docs" secret=test_ajp_secret
ProxyPass "/manager/" "ajp://tomcat.container:8009/manager/" secret=test_ajp_secret

Afterwards it works.