diff --git a/source/net/yacy/http/AbstractRemoteHandler.java b/source/net/yacy/http/AbstractRemoteHandler.java index 932571774..6f42fe83f 100644 --- a/source/net/yacy/http/AbstractRemoteHandler.java +++ b/source/net/yacy/http/AbstractRemoteHandler.java @@ -97,7 +97,7 @@ abstract public class AbstractRemoteHandler extends AbstractHandler implements H String remoteHost = request.getRemoteHost(); InetAddress remoteIP = Domains.dnsResolve(remoteHost); - if (!remoteIP.isAnyLocalAddress()) return; + if (!remoteIP.isAnyLocalAddress() && !remoteIP.isLoopbackAddress()) return; handleRemote(target, baseRequest, request, response); diff --git a/source/net/yacy/http/ProxyHandler.java b/source/net/yacy/http/ProxyHandler.java index 812156633..f247290c5 100644 --- a/source/net/yacy/http/ProxyHandler.java +++ b/source/net/yacy/http/ProxyHandler.java @@ -29,11 +29,13 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.SocketException; +import java.util.Date; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.yacy.cora.date.GenericFormatter; import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.HeaderFramework; @@ -51,6 +53,7 @@ import org.eclipse.jetty.server.Request; import net.yacy.crawler.data.Cache; import net.yacy.crawler.retrieval.Response; import net.yacy.peers.operation.yacyBuildProperties; +import net.yacy.server.http.HTTPDProxyHandler; import net.yacy.server.http.MultiOutputStream; /** @@ -234,8 +237,9 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler { } // we handled this request, break out of handler chain - baseRequest.setHandled(true); - } + logProxyAccess(request); + baseRequest.setHandled(true); + } private void setViaHeader(final HeaderFramework header, final String httpVer) { if (!sb.getConfigBool("proxy.sendViaHeader", true)) return; @@ -262,5 +266,33 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler { header.put(HeaderFramework.VIA, viaValue.toString()); } } + + public final static synchronized void logProxyAccess(HttpServletRequest request) { + + final StringBuilder logMessage = new StringBuilder(80); + + // Timestamp + logMessage.append(GenericFormatter.SHORT_SECOND_FORMATTER.format(new Date())); + logMessage.append(' '); + + // Remote Host + final String clientIP = request.getRemoteAddr(); + logMessage.append(clientIP); + logMessage.append(' '); + // Method + final String requestMethod = request.getMethod(); + logMessage.append(requestMethod); + logMessage.append(' '); + + // URL + logMessage.append(request.getRequestURL()); + final String requestArgs = request.getQueryString(); + if (requestArgs != null) { + logMessage.append("?").append(requestArgs); + } + + HTTPDProxyHandler.proxyLog.fine(logMessage.toString()); + + } } diff --git a/source/net/yacy/server/http/HTTPDProxyHandler.java b/source/net/yacy/server/http/HTTPDProxyHandler.java index 1e554cffc..0fa7b9270 100644 --- a/source/net/yacy/server/http/HTTPDProxyHandler.java +++ b/source/net/yacy/server/http/HTTPDProxyHandler.java @@ -215,7 +215,7 @@ public final class HTTPDProxyHandler { * Special logger instance for proxy access logging much similar * to the squid access.log file */ - private static final ConcurrentLog proxyLog = new ConcurrentLog("PROXY.access"); + public static final ConcurrentLog proxyLog = new ConcurrentLog("PROXY.access"); /** * Reusable {@link StringBuilder} for logging