We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug ctx.ClientIP() can't parse X-Forwarded-For while using Unix Domain Sock.
ctx.ClientIP()
X-Forwarded-For
To Reproduce
import ( "context" "github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/app/server" "github.com/cloudwego/hertz/pkg/common/config" ) func main() { options := []config.Option{ server.WithHostPorts("ingress.sock"), server.WithNetwork("unix"), } h := server.Default(options...) h.GET("/hello", func(c context.Context, ctx *app.RequestContext) { clientIp := ctx.ClientIP() ctx.JSON(200, map[string]any{ "header": ctx.Request.Header.Get("X-Forwarded-For"), "client_ip": clientIp, }) }) h.Spin() }
run socat to emulate a nginx:
socat
socat TCP-LISTEN:12345 UNIX-CONNECT:ingress.sock
Expected behavior
header = client_ip in the response body.
header
client_ip
Screenshots
Hertz version:
v0.9.5
The text was updated successfully, but these errors were encountered:
YangruiEmma
Successfully merging a pull request may close this issue.
Describe the bug
ctx.ClientIP()
can't parseX-Forwarded-For
while using Unix Domain Sock.To Reproduce
run
socat
to emulate a nginx:Expected behavior
header
=client_ip
in the response body.Screenshots
Hertz version:
v0.9.5
The text was updated successfully, but these errors were encountered: