From 245265cb27c8f26639778187270f5a3de73a94e5 Mon Sep 17 00:00:00 2001 From: Mitch Gaffigan Date: Sat, 18 Oct 2025 11:00:45 -0500 Subject: [PATCH 1/2] Allow specifying a proxy for http API connections via mirthApi.http.proxyHost Signed-off-by: Mitch Gaffigan --- .../connect/client/core/ServerConnection.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/src/com/mirth/connect/client/core/ServerConnection.java b/server/src/com/mirth/connect/client/core/ServerConnection.java index 2b5050180..1e78d052a 100644 --- a/server/src/com/mirth/connect/client/core/ServerConnection.java +++ b/server/src/com/mirth/connect/client/core/ServerConnection.java @@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.StatusLine; @@ -134,7 +135,20 @@ public ServerConnection(int timeout, String[] httpsProtocols, String[] httpsCiph cookieStore = new BasicCookieStore(); socketConfig = SocketConfig.custom().setSoTimeout(timeout).build(); - requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(timeout).build(); + + RequestConfig.Builder requestConfigBuilder = RequestConfig.custom() + .setConnectTimeout(CONNECT_TIMEOUT) + .setSocketTimeout(timeout); + + // If HTTP Proxy is set, configure it + String httpProxyHost = System.getProperty("mirthApi.http.proxyHost"); + if (allowHTTP && StringUtils.isNotBlank(httpProxyHost)) { + String httpProxyPort = System.getProperty("mirthApi.http.proxyPort"); + int proxyPort = StringUtils.isNotBlank(httpProxyPort) ? Integer.parseInt(httpProxyPort) : 8888; + requestConfigBuilder.setProxy(new HttpHost(httpProxyHost, proxyPort)); + } + + requestConfig = requestConfigBuilder.build(); keepAliveStrategy = new CustomKeepAliveStrategy(); createClient(); From e96f62df4410a9766b5cdfb1ae71624e016c7390 Mon Sep 17 00:00:00 2001 From: Mitch Gaffigan Date: Tue, 4 Nov 2025 10:50:55 -0600 Subject: [PATCH 2/2] Add log message on use of proxy Signed-off-by: Mitch Gaffigan --- server/src/com/mirth/connect/client/core/ServerConnection.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/com/mirth/connect/client/core/ServerConnection.java b/server/src/com/mirth/connect/client/core/ServerConnection.java index 1e78d052a..5c1dda351 100644 --- a/server/src/com/mirth/connect/client/core/ServerConnection.java +++ b/server/src/com/mirth/connect/client/core/ServerConnection.java @@ -145,6 +145,7 @@ public ServerConnection(int timeout, String[] httpsProtocols, String[] httpsCiph if (allowHTTP && StringUtils.isNotBlank(httpProxyHost)) { String httpProxyPort = System.getProperty("mirthApi.http.proxyPort"); int proxyPort = StringUtils.isNotBlank(httpProxyPort) ? Integer.parseInt(httpProxyPort) : 8888; + logger.info("Using API HTTP Proxy {}:{}", httpProxyHost, proxyPort); requestConfigBuilder.setProxy(new HttpHost(httpProxyHost, proxyPort)); }