diff --git a/jetty-distribution/src/main/resources/bin/jetty.sh b/jetty-distribution/src/main/resources/bin/jetty.sh index 332be7f6ea2..62a94044939 100755 --- a/jetty-distribution/src/main/resources/bin/jetty.sh +++ b/jetty-distribution/src/main/resources/bin/jetty.sh @@ -68,7 +68,8 @@ # # JETTY_RUN # Where the jetty.pid file should be stored. It defaults to the -# first available of /var/run, /usr/var/run, and /tmp if not set. +# first available of /var/run, /usr/var/run, JETTY_HOME and /tmp +# if not set. # # JETTY_PID # The Jetty PID file, defaults to $JETTY_RUN/jetty.pid diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java index 12e9f1076cc..a7ff888fdcd 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/StatisticsServlet.java @@ -22,6 +22,8 @@ import java.io.IOException; import java.io.PrintWriter; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; +import java.net.InetAddress; +import java.net.UnknownHostException; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -110,7 +112,7 @@ public class StatisticsServlet extends HttpServlet } if (_restrictToLocalhost) { - if (!"127.0.0.1".equals(req.getRemoteAddr())) + if (!isLoopbackAddress(req.getRemoteAddr())) { resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); return; @@ -132,12 +134,20 @@ public class StatisticsServlet extends HttpServlet } - - - /** - * @param response - * @throws IOException - */ + private boolean isLoopbackAddress(String address) + { + try + { + InetAddress addr = InetAddress.getByName(address); + return addr.isLoopbackAddress(); + } + catch (UnknownHostException e ) + { + LOG.warn("Warning: attempt to access statistics servlet from " + address, e); + return false; + } + } + private void sendXmlResponse(HttpServletResponse response) throws IOException { StringBuilder sb = new StringBuilder();