STUDY/스프링
[스프링부트] 2.4.x 버전에서 내장 톰캣 AJP 프로토콜 띄우기 (secretRequired 이슈)
simongs
2021. 3. 30. 00:25
작업환경
- Spring Boot 2.4.4
- EmbedTomcat 9.x
배경
- APACHE <-> TOMCAT 통신을 위한 AJP 프로토콜 띄우기
이슈사항
- 인터넷에 나와있는 코드를 따라하는데 아래와 같은 이슈 발생
- TOMCAT 특정 버전이후로 secretRequired 값이 default true로 먹는 이슈
[2021/03/30 00:21:22.962][main][ERROR][LifecycleBase:175] Failed to start component [Connector[AJP/1.3-8009]]
org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1075)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
Caused by: java.lang.IllegalArgumentException: The AJP Connector is configured with secretRequired="true" but the secret attribute is either null or "". This combination is not valid.
at org.apache.coyote.ajp.AbstractAjpProtocol.start(AbstractAjpProtocol.java:270)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1072)
...
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8009 failed to start.
The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8009, or configure this application to listen on another port.
작업코드
@Configuration
public class TomcatConfiguration {
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createAjpConnector());
return tomcat;
}
private Connector createAjpConnector() {
Connector ajpConnector = new Connector("AJP/1.3");
ajpConnector.setPort(8009);
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme("http");
((AbstractAjpProtocol) ajpConnector.getProtocolHandler()).setSecretRequired(false); // 해당 줄을 추가함
return ajpConnector;
}
}