레이블이 Spring Boot인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Spring Boot인 게시물을 표시합니다. 모든 게시물 표시

2020년 5월 10일 일요일

Spring Boot AJP 설정

Apache의 mod_jk 구성이 필요합니다.

- Tomcat
@Configuration
public class TomcatConfiguration {

@Bean
public WebServerFactory servletContainer() {

TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Connector ajp = new Connector("AJP/1.3");
ajp.setPort(8009);
ajp.setSecure(false);
ajp.setAllowTrace(false);
ajp.setScheme("http");
ProtocolHandler protocolHandler = ajp.getProtocolHandler();
if (protocolHandler instanceof AbstractAjpProtocol) {
AbstractAjpProtocol<?> abstractAjpProtocol = (AbstractAjpProtocol<?>) protocolHandler;
abstractAjpProtocol.setSecretRequired(false);
}
factory.addAdditionalTomcatConnectors(ajp);

return factory;
}

}


메이븐 설정은 spring-boot-starter-tomcat이 필요합니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>





- Undertow
@Configuration
public class UndertowConfiguration {

@Bean
public ServletWebServerFactory servletContainer() {
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {

@Override
public void customize(Builder builder) {
builder.addAjpListener(8009, "127.0.0.1");
}
});
return factory;
}

}


메이븐 설정은 spring-boot-starter-undertow이 필요하고 undertow 구성 시 spring-boot-starter-tomcat을 제외해야 합니다.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>