Skip to content

Commit

Permalink
allow specifying AJP listen address
Browse files Browse the repository at this point in the history
  • Loading branch information
danthe1st committed Nov 22, 2024
1 parent 59089ec commit 808c52f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/net/discordjug/javabot/api/TomcatConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.InetAddress;

import net.discordjug.javabot.data.config.SystemsConfig;


Expand All @@ -18,6 +20,7 @@
public class TomcatConfig {

private final int ajpPort;
private final InetAddress ajpAddress;
private final boolean tomcatAjpEnabled;
private final SystemsConfig systemsConfig;

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

/**
Expand All @@ -46,6 +51,7 @@ TomcatServletWebServerFactory servletContainer() {
Connector ajpConnector = new Connector("org.apache.coyote.ajp.AjpNioProtocol");
AjpNioProtocol protocol= (AjpNioProtocol) ajpConnector.getProtocolHandler();
protocol.setSecret(systemsConfig.getApiConfig().getAjpSecret());
protocol.setAddress(ajpAddress);
ajpConnector.setPort(ajpPort);
ajpConnector.setSecure(true);
tomcat.addAdditionalTomcatConnectors(ajpConnector);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ server.address=127.0.0.1
server.port=9000
tomcat.ajp.port=9001
tomcat.ajp.enabled=true
tomcat.ajp.address=127.0.0.1

0 comments on commit 808c52f

Please sign in to comment.