Open bangbaew opened 1 year ago
@bangbaew Is the rust version also running inside Docker?
Found the issue. We are using the ClientIP from the context here: https://github.com/gofiber/contrib/blob/main/otelfiber/semconv.go#L59
We need to add support for X-Forwarded-For
.
Related issue: https://github.com/open-telemetry/opentelemetry-go/issues/2282
I do think this should probably be fixed in Fiber instead of the middleware. Someone reported a similar issue when using c.IP()
a few days ago on discord.
@bangbaew Is the rust version also running inside Docker?
It's running inside a container, same network as the Gofiber app. This is the Rust library i use: https://github.com/OutThereLabs/actix-web-opentelemetry
@bangbaew Is the rust version also running inside Docker?
It's running inside a container, same network as the Gofiber app. This is the Rust library i use: https://github.com/OutThereLabs/actix-web-opentelemetry
Yeah, this is a Fiber bug.
We can probably solve this by using this: https://docs.gofiber.io/api/ctx#ips
@bangbaew Is the rust version also running inside Docker?
It's running inside a container, same network as the Gofiber app. This is the Rust library i use: https://github.com/OutThereLabs/actix-web-opentelemetry
Yeah, this is a Fiber bug.
Yeah, the log IPs on the terminal as well, they all are local IPs, and I don't think they're any useful.
@bangbaew Is the rust version also running inside Docker?
It's running inside a container, same network as the Gofiber app. This is the Rust library i use: https://github.com/OutThereLabs/actix-web-opentelemetry
Yeah, this is a Fiber bug.
Yeah, the log IPs on the terminal as well, they all are local IPs, and I don't think they're any useful.
Those are expected since thats your IP inside the container. They only way to get the real IP in the logs is by parsing the Forwarded headers, it should be the first one in the List.
In one of your routes log ctx.IPs()
https://github.com/gofiber/fiber/blob/634f163e3f6292e658e61d0dd9e3c475d87b5d54/ctx.go#L699-L701
https://docs.gofiber.io/next/api/fiber#config
did you configure this header ? otherwise the fiber app can not determine the real ip
@gaby maybe we should extend the doc for these cases (ip method)
https://github.com/gofiber/fiber/blob/634f163e3f6292e658e61d0dd9e3c475d87b5d54/ctx.go#L699-L701
https://docs.gofiber.io/next/api/fiber#config
did you configure this header ? otherwise the fiber app can not determine the real ip
@gaby maybe we should extend the doc for these cases (ip method)
Agree, it's a bit confusing. From a otelfiber perspective using c.IPs()
may be better since opentelemetry will auto-parse the list and only use the first IP which is the real client IP.
@bangbaew have you ever tested what you get when you configure the header of the proxy (mostly forwarded-for ) in your fiber app ?
@bangbaew have you ever tested what you get when you configure the header of the proxy (mostly forwarded-for ) in your fiber app ?
If you mean have I tried logging from C.IPs()
and c.GetReqHeaders()
, I've tried them and the real IPs are shown in the fmt.Println, they both echo the X-Forwarded-For
If I send a request over Kong Gateway endpoint, it will log this
"X-Forwarded-For": "{my real public ip}, 10.8.26.4",
"X-Real-Ip": "10.8.26.4"
The 10.8.26.4 is Kong instance's IP.
If I send a request directly, it will log this
"X-Forwarded-For": "{my real public ip}",
"X-Real-Ip": "{my real public ip}"
but both of them will log this in Jaeger UI
When make a remote request to my Gofiber endpoint, it gives http.client_ip = 10.8.11.189, which is container's local ip, but in Rust version of opentelemetry, used with Actix Web, it gives my real public ip out there, how can I make Gofiber's otel show public client ip?