Skip to content
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

It is recommended to add X-Forwarded-For in ctx of rpc server package #527

Open
du5 opened this issue Sep 30, 2024 · 0 comments
Open

It is recommended to add X-Forwarded-For in ctx of rpc server package #527

du5 opened this issue Sep 30, 2024 · 0 comments

Comments

@du5
Copy link

du5 commented Sep 30, 2024

bsc-erigon/rpc/http.go

Lines 257 to 258 in f10d0fe

ctx = context.WithValue(ctx, peerInfoContextKey{}, connInfo)

if xForward := r.Header.Get("X-Forwarded-For"); xForward != "" {
	ctx = context.WithValue(ctx, "X-Forwarded-For", xForward)
}

Can restore the information of visitors through reverse proxy or source CDN

For example

addr := conn.remoteAddr()
if v := connCtx.Value("X-Forwarded-For"); v != nil {
	addr = v.(string)
}
h.logger = h.logger.New("conn", addr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant