X-Forwarded-For field doesn't appear.
It seems reading X-Forwarded-For header from incoming messages is not working. I configured GELF HTTP input, which gets logs through HAProxy with 'forwardfor' option, and 'trusted_proxies' in graylog.conf. But I can't see real client IP anywhere, just IP of HAProxy is everywhere.
Environment
- Graylog Version: 2.0.3-1
- Operating System: Debian 8.5
@oleg1628 Can you see if the workarounds outlined in https://github.com/Graylog2/graylog2-server/issues/1102 work for you?
Otherwise this is a feature request, the HTTP input does not currently support this.
It would be nice to get X-Forwarded-For IP in some message field from GELF HTTP input. I have many mobile clients behind NAT which send GELF HTTP messages through my reverse proxy (HAProxy) to Graylog. HAProxy sets X-Forwarded-For field, but I can't see it in Graylog now.
I've been using workaround with nginx + lua (openresty). I modify HTTP request body with lua. which is in json format and always has "}}" in the end in my case.
server {
listen 80;
server_name fqdn;
location /<location1> {
content_by_lua '
ngx.req.read_body()
local body = ngx.req.get_body_data()
local realip = ngx.req.get_headers()["X-Forwarded-For"]
local append = [[,"host":"]] .. realip .. [["]]
local newbody = ngx.re.sub(body, "}}", append .. "${0}")
res = ngx.location.capture("/gelf", {method = ngx.HTTP_POST, body = newbody})
ngx.print(res.body)
';
}
location /gelf {
proxy_pass http://127.0.0.1:12205/gelf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Thanks for the workaround @oleg1628 ! That really helped me out, good idea.
Can we bring this back to life? I'm curious if anything ever came about with this, as using the GELF HTTP endpoint does not forward the client IP address.
@kyl3n you might want to take this PR and rebase it to the current master:
https://github.com/Graylog2/graylog2-server/pull/3255
and open a PR
Closing this issue - going to continue to track via https://github.com/Graylog2/graylog2-server/issues/11339