This is an automated email from the ASF dual-hosted git repository. penghui pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 84575578dbebffd97fa1cf603a7c4cee822088a8 Author: Shoothzj <[email protected]> AuthorDate: Tue Dec 29 13:46:54 2020 +0800 Fix Proxy Config bindAddress does not working for servicePort (#9068) The proxy config bindAddress, only works for webPort, does not work for the servicePort. (cherry picked from commit 29921a63bc9b55aa0349d77a5b2c5459dd3cc6e4) --- conf/proxy.conf | 3 +++ .../src/main/java/org/apache/pulsar/proxy/server/ProxyService.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conf/proxy.conf b/conf/proxy.conf index 820eca3..91b0196 100644 --- a/conf/proxy.conf +++ b/conf/proxy.conf @@ -46,6 +46,9 @@ zooKeeperCacheExpirySeconds=300 ### --- Server --- ### +# Hostname or IP address the service binds on, default is 0.0.0.0. +bindAddress=0.0.0.0 + # Hostname or IP address the service advertises to the outside world. # If not set, the value of `InetAddress.getLocalHost().getHostname()` is used. advertisedAddress= diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java index c25484c..e45f9c6 100644 --- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java +++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java @@ -177,7 +177,7 @@ public class ProxyService implements Closeable { // Bind and start to accept incoming connections. if (proxyConfig.getServicePort().isPresent()) { try { - listenChannel = bootstrap.bind(proxyConfig.getServicePort().get()).sync().channel(); + listenChannel = bootstrap.bind(proxyConfig.getBindAddress(), proxyConfig.getServicePort().get()).sync().channel(); LOG.info("Started Pulsar Proxy at {}", listenChannel.localAddress()); } catch (Exception e) { throw new IOException("Failed to bind Pulsar Proxy on port " + proxyConfig.getServicePort().get(), e); @@ -187,7 +187,7 @@ public class ProxyService implements Closeable { if (proxyConfig.getServicePortTls().isPresent()) { ServerBootstrap tlsBootstrap = bootstrap.clone(); tlsBootstrap.childHandler(new ServiceChannelInitializer(this, proxyConfig, true)); - listenChannelTls = tlsBootstrap.bind(proxyConfig.getServicePortTls().get()).sync().channel(); + listenChannelTls = tlsBootstrap.bind(proxyConfig.getBindAddress(), proxyConfig.getServicePortTls().get()).sync().channel(); LOG.info("Started Pulsar TLS Proxy on {}", listenChannelTls.localAddress()); }
