Comments (18)
@bangbaew Is the rust version also running inside Docker?
from contrib.
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: 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 c.IP()
a few days ago on discord.
from contrib.
@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
from contrib.
@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.
from contrib.
We can probably solve this by using this: https://docs.gofiber.io/api/ctx#ips
from contrib.
@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.
from contrib.
@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()
from contrib.
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)
from contrib.
https://github.com/gofiber/fiber/blob/master/ctx_test.go#L1265
from contrib.
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 c.IPs()
may be better since opentelemetry will auto-parse the list and only use the first IP which is the real client IP.
from contrib.
@bangbaew have you ever tested what you get when you configure the header of the proxy (mostly forwarded-for ) in your fiber app ?
from contrib.
@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
http.client_ip | 10.8.51.49 |
---|
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 configure the header of the proxy
in my fiber app.
from contrib.
But I don't know how to configure the header of the proxy in my fiber app.
@bangbaew like this
app := fiber.New(fiber.Config{
ProxyHeader: fiber.HeaderXForwardedFor,
})
https://docs.gofiber.io/next/api/fiber#config
from contrib.
But I don't know how to configure the header of the proxy in my fiber app.
@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?
from contrib.
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
https://github.com/gofiber/contrib/tree/main/otelfiber#readme
from contrib.
https://docs.gofiber.io/next/api/ctx#ip
from contrib.
@bangbaew opentelemetry says they only take the first value. Has that been the case for you after adding the header?
from contrib.
maybe we can change the middleware and cut away the second value which comes back through the header
from contrib.
Related Issues (20)
- 🚀 [Feature]: My (simple) SSEFiber Package HOT 1
- 🤗 [Question]: Could you mint a new release? HOT 3
- 🤗 [Question]: Not sure how the socket.io requests are being handled HOT 5
- 🐛 [Bug]: Websocket write tcp4 127.0.0.1:8001->127.0.0.1:59510: write: broken pipe HOT 3
- 🤗 [Question]: websocket.Conn.Locals vs fiber.Ctx.Locals signature difference
- 🤗 [Question]: How does socketio differentiate between TextMessage and BinaryMessage? HOT 4
- 🚀 [Feature]: JWT unsupport fiber v3 HOT 5
- 🚀 [Feature]: contrib/swagger.go exposes internal adresses. There should be a possibility to self-host
- 🐛 [Bug]: Otelfiber blocks stream writers HOT 1
- 🐛 [Bug]: Segfault with WS compression HOT 2
- 🤗 [Question]: Is there any updates about fiber v3 support for middlewares such a otelfiber? HOT 3
- 🚀 [Feature]: i18n refactoring from middleware to global container HOT 2
- 🚀 [Feature]: Support Cerbos HOT 5
- 🚀 [Feature]: Custom metric attributes for otelfiber
- 🤗 [Question]: How to do Sync on fiberzap? Is that necessary? HOT 3
- 🐛 [Bug]: error occored when import github.com/gofiber/contrib/websocket HOT 7
- 🚀 [Feature]: Otelfiber allow for manual cancellation of c.UserContext() in otelfiber.Middleware() HOT 1
- 🐛 [Bug]: FiberSentry: GetHubFromContext() never returns nil
- 🚀 [Feature]: Add golangci-lint
- 🤗 [Question]: fiberzerolog the banner is not printed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contrib.