5

I have a webserver which receives the client's IP from the load balancer via the X-Forwarded-For header, but does not forward it to the GraphQL server, making debugging more difficult.

Is it possible to turn this on, or would it require a patch to react-dom/server? How have others solved the problem of gathering contextual data in the graphql server request logs when they are triggered by a server-side-renderer?

Grokify
  • 15,092
  • 6
  • 60
  • 81
Andrey Fedorov
  • 9,148
  • 20
  • 67
  • 99
  • You need tell more about which Load Balancer? Also does the LB interact directly with GraphQL server or how? This is a infrastructure dependent question and should include the infra details as well – Tarun Lalwani May 13 '18 at 15:44
  • @TarunLalwani the LB interacts with the GraphQL server through the webserver’s server side renderer, which uses the react/dom-server library – Andrey Fedorov May 13 '18 at 15:55
  • Which LB? AWS or something else. Also if you take LB out of picture the IP can be seen correctly? – Tarun Lalwani May 13 '18 at 16:53
  • I don't think the LB is in the picture, it just passes an X-Forwarded-For header which I know how to extract and would like to pass to `react-dom/server` to forward to the database. – Andrey Fedorov May 14 '18 at 18:57
  • I think now I get it, you use a graphql-client on server which makes the IP come as your server ip for every request and you want to actually see the client ip which triggered the server renderer. Right? – Tarun Lalwani May 15 '18 at 06:48
  • Yup! I see an internal webserver IP in my graphql logs and no user agent header where I would like to see some headers that would allow me to at least tie the two log statements together. – Andrey Fedorov May 15 '18 at 06:50
  • I am not sure if it is possible straight away, but if you provide a ready to use environment using docker-compose or something, I might be able to dig further and help you out. Else setting up the whole environment to reproduce the condition may take too much time for me – Tarun Lalwani May 15 '18 at 06:53
  • It’s a k8s environment with svc local DNS touting. Whatever the library sends the GraphQL server is what it gets in headers — k8s does not any headers on application layer, I don’t think? Can test and verify tomorrow. – Andrey Fedorov May 15 '18 at 06:54
  • A repo with `deploy.sh` will also work even if it is a `k8s`, I have a local `k8s` minikube with me – Tarun Lalwani May 15 '18 at 06:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/171083/discussion-between-tarun-lalwani-and-andrey-fedorov). – Tarun Lalwani May 15 '18 at 11:50

1 Answers1

0

I'll dig into the source shortly to verify, but it doesn't seem like this is actually possible at this time.

Andrey Fedorov
  • 9,148
  • 20
  • 67
  • 99