From 9543e2c3f7ae725f0829306e0d94b1aee01ea58f Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Thu, 30 Apr 2020 14:36:16 +0200 Subject: Ignore local port reported from proxy-protocol header Replace usage of ServletRequest.getLocalPort() with equivalent from ServerConnector. The latter will not be overridden by the proxy-protocol header if proxy-protocol is enabled for that connector. --- .../java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java') diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java index 0074f5cfe89..d8b649c9db8 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java +++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLogRequestLog.java @@ -18,6 +18,8 @@ import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; +import static com.yahoo.jdisc.http.core.HttpServletRequestUtils.getConnectorLocalPort; + /** * This class is a bridge between Jetty's {@link org.eclipse.jetty.server.handler.RequestLogHandler} * and our own configurable access logging in different formats provided by {@link AccessLog}. @@ -80,7 +82,7 @@ public class AccessLogRequestLog extends AbstractLifeCycle implements RequestLog } accessLogEntry.setHttpVersion(request.getProtocol()); accessLogEntry.setScheme(request.getScheme()); - accessLogEntry.setLocalPort(request.getLocalPort()); + accessLogEntry.setLocalPort(getConnectorLocalPort(request)); Principal principal = (Principal) request.getAttribute(ServletRequest.JDISC_REQUEST_PRINCIPAL); if (principal != null) { accessLogEntry.setUserPrincipal(principal); -- cgit v1.2.3