Skip to content

Commit 808c52f

Browse files
committed
allow specifying AJP listen address
1 parent 59089ec commit 808c52f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/net/discordjug/javabot/api/TomcatConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.Configuration;
99

10+
import java.net.InetAddress;
11+
1012
import net.discordjug.javabot.data.config.SystemsConfig;
1113

1214

@@ -18,6 +20,7 @@
1820
public class TomcatConfig {
1921

2022
private final int ajpPort;
23+
private final InetAddress ajpAddress;
2124
private final boolean tomcatAjpEnabled;
2225
private final SystemsConfig systemsConfig;
2326

@@ -26,11 +29,13 @@ public class TomcatConfig {
2629
* @param ajpPort The port to run AJP under
2730
* @param tomcatAjpEnabled <code>true</code> if AJP is enabled, else <code>false</code>
2831
* @param systemsConfig an object representing the configuration of various systems
32+
* @param ajpAddress the listen address for AJP
2933
*/
30-
public TomcatConfig(@Value("${tomcat.ajp.port}") int ajpPort, @Value("${tomcat.ajp.enabled}") boolean tomcatAjpEnabled, SystemsConfig systemsConfig) {
34+
public TomcatConfig(@Value("${tomcat.ajp.port}") int ajpPort, @Value("${tomcat.ajp.enabled}") boolean tomcatAjpEnabled, @Value("${tomcat.ajp.address}") InetAddress ajpAddress, SystemsConfig systemsConfig) {
3135
this.ajpPort = ajpPort;
3236
this.tomcatAjpEnabled = tomcatAjpEnabled;
3337
this.systemsConfig = systemsConfig;
38+
this.ajpAddress = ajpAddress;
3439
}
3540

3641
/**
@@ -46,6 +51,7 @@ TomcatServletWebServerFactory servletContainer() {
4651
Connector ajpConnector = new Connector("org.apache.coyote.ajp.AjpNioProtocol");
4752
AjpNioProtocol protocol= (AjpNioProtocol) ajpConnector.getProtocolHandler();
4853
protocol.setSecret(systemsConfig.getApiConfig().getAjpSecret());
54+
protocol.setAddress(ajpAddress);
4955
ajpConnector.setPort(ajpPort);
5056
ajpConnector.setSecure(true);
5157
tomcat.addAdditionalTomcatConnectors(ajpConnector);

src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ server.address=127.0.0.1
22
server.port=9000
33
tomcat.ajp.port=9001
44
tomcat.ajp.enabled=true
5+
tomcat.ajp.address=127.0.0.1

0 commit comments

Comments
 (0)