I'm trying to use AJP protocol to communicate with the app created using Spring Boot 2.2.6 with embedded Tomcat and containerised using this official guide. My server uses Apache Server to proxy all requests to different apps and containerised Spring boot app is one of them. Communication works just fine when using http - AJP communication doesn't work though. Moreover, it works just fine when I didn't containerised the app and just launch it using java command-line tool.
I'm using AJPing script to check AJP access.
And here is AJP connector configuration:
@Configuration
public class TomcatConfiguration implements WebServerFactoryCustomizer<TomcatServletWebServerFactory>
{
@Value( "${tomcat.ajp.secret}" )
String ajpSecret;
@Override
public void customize( TomcatServletWebServerFactory factory )
{
factory.addAdditionalTomcatConnectors( ajpConnector() );
}
private Connector ajpConnector()
{
Connector connector = new Connector( "AJP/1.3" );
AjpNioProtocol protocol = (AjpNioProtocol) connector.getProtocolHandler();
protocol.setSecret( ajpSecret );
connector.setPort( 8009 );
connector.setSecure( true );
return connector;
}
}
So I investigated this issue by checking what ports are used in container:
and here is a result I got:
So I could see that port 8009 used by AJP was there, but bind-address was different than the one used by port 8080. So setting up port address to "0.0.0.0" resolved my problem, but I can't say I fully understand it - here is the configuration with a fix: