-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get client's real ip? #507
Comments
@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 Related issue: open-telemetry/opentelemetry-go#2282 I do think this should probably be fixed in Fiber instead of the middleware. Someone reported a similar issue when using |
It's running inside a container, same network as the Gofiber app. |
Yeah, this is a Fiber bug. |
We can probably solve this by using this: https://docs.gofiber.io/api/ctx#ips |
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 |
Lines 59 to 62 in bae3c8c
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 |
@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
The 10.8.26.4 is Kong instance's IP. If I send a request directly, it will log this
but both of them will log this in Jaeger UI
You can see that the http.client_ip in Jaeger UI is the fiber instance's local ip, not even the forwarded IPs. But I don't know how to |
@bangbaew like this app := fiber.New(fiber.Config{
ProxyHeader: fiber.HeaderXForwardedFor,
}) |
Thanks a lot! it shows the X-Forwarded-For IPs now, with both public IP and API Gateway's IP, can I make it record only the first value? |
do not think so, I would have to research in any case, we should expand the documentation @bangbaew you can do that, you know best where you searched for the solution of the problem maybe in the examples and as a hint in the readme |
@bangbaew opentelemetry says they only take the first value. Has that been the case for you after adding the header? |
maybe we can change the middleware and cut away the second value which comes back through the header |
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?
The text was updated successfully, but these errors were encountered: