Hi guys, I have the following setup:
HAProxy (Layer 4) --> Traefik Cluster in kubernetes deployed using the daemonset.
And I just did enable the accessLog to get the source IPs of each request, so I went to HAProxy configuration and enabled the option forwardfor
and configured traefik logs like this:
[accessLog]
filePath = "/logs/access.log"
format = "json"
bufferingSize = 100
[accessLog.fields]
defaultMode = "keep"
[accessLog.fields.headers]
defaultMode = "keep"
[accessLog.fields.headers.names]
"X-Forwarded-For" = "keep"
But I can't see the client source address in the logs, this is what I get:
{
"BackendAddr": "10.244.5.23:9000",
"BackendName": "https_main.domain.xyz",
"BackendURL": {
"Scheme": "http",
"Opaque": "",
"User": null,
"Host": "10.244.5.23:9000",
"Path": "",
"RawPath": "",
"ForceQuery": false,
"RawQuery": "",
"Fragment": ""
},
"ClientAddr": "192.168.128.4:34326",
"ClientHost": "192.168.128.4",
"ClientPort": "34326",
"ClientUsername": "-",
"DownstreamContentSize": 2450,
"DownstreamStatus": 200,
"DownstreamStatusLine": "200 OK",
"Duration": 5536065,
"FrontendName": "https_main.domain.xyz",
"OriginContentSize": 2450,
"OriginDuration": 5153418,
"OriginStatus": 200,
"OriginStatusLine": "200 OK",
"Overhead": 382647,
"RequestAddr": "main.domain.xyz",
"RequestContentSize": 0,
"RequestCount": 39,
"RequestHost": "main.domain.xyz",
"RequestLine": "GET / HTTP/1.0",
"RequestMethod": "GET",
"RequestPath": "/",
"RequestPort": "-",
"RequestProtocol": "HTTP/1.0",
"RetryAttempts": 0,
"StartLocal": "2019-08-14T10:10:29.989624291Z",
"StartUTC": "2019-08-14T10:10:29.989624291Z",
"downstream_Accept-Ranges": "bytes",
"downstream_Cache-Control": "public, max-age=0",
"downstream_Content-Type": "text/html; charset=UTF-8",
"downstream_Date": "Wed, 14 Aug 2019 10:10:29 GMT",
"downstream_Etag": "W/\"992-16c6b837cb8\"",
"downstream_Last-Modified": "Wed, 07 Aug 2019 09:57:55 GMT",
"downstream_Vary": "Accept-Encoding",
"downstream_X-Powered-By": "Express",
"level": "info",
"msg": "",
"origin_Accept-Ranges": "bytes",
"origin_Cache-Control": "public, max-age=0",
"origin_Content-Type": "text/html; charset=UTF-8",
"origin_Date": "Wed, 14 Aug 2019 10:10:29 GMT",
"origin_Etag": "W/\"992-16c6b837cb8\"",
"origin_Last-Modified": "Wed, 07 Aug 2019 09:57:55 GMT",
"origin_Vary": "Accept-Encoding",
"origin_X-Powered-By": "Express",
"request_Accept": "*/*",
"request_Connection": "Keep-Alive",
"request_User-Agent": "ApacheBench/2.3",
"time": "2019-08-14T10:10:29Z"
}
So the ClientAddr is the HAProxy's IP which is probably normal, but I expected to get also the X-Forwarded-For header.
Am I missing anything?
Thanks.