diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java index 989d8d7fec..0b3a8bedd8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderHandler.java @@ -18,6 +18,7 @@ package org.apache.nifi.web.server; import java.io.IOException; import java.io.PrintWriter; +import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -60,6 +61,12 @@ public class HostHeaderHandler extends ScopedHandler { validHosts.add("localhost:" + serverPort); // Different from customizer -- empty is ok here validHosts.add(""); + try { + validHosts.add(InetAddress.getLocalHost().getHostName()); + validHosts.add(InetAddress.getLocalHost().getHostName() + ":" + serverPort); + } catch (final Exception e) { + logger.warn("Failed to determine local hostname.", e); + } logger.info("Created " + this.toString()); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderSanitizationCustomizer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderSanitizationCustomizer.java index 9d55d71816..5a10610246 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderSanitizationCustomizer.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/HostHeaderSanitizationCustomizer.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.server; +import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -53,6 +54,12 @@ public class HostHeaderSanitizationCustomizer implements HttpConfiguration.Custo // Sometimes the hostname is left empty but the port is always populated validHosts.add("localhost"); validHosts.add("localhost:" + serverPort); + try { + validHosts.add(InetAddress.getLocalHost().getHostName()); + validHosts.add(InetAddress.getLocalHost().getHostName() + ":" + serverPort); + } catch (final Exception e) { + logger.warn("Failed to determine local hostname.", e); + } logger.info("Created " + this.toString()); }