h2conn
h2conn copied to clipboard
Can it support reverse proxy such as nginx?
When I put the server behind nginx, and try to connect with h2.Connect()
, it throws an error:
stream error: stream ID 3; PROTOCOL_ERROR
In the mean time, doing a normal GET over HTTP2 client works fine
Does it work for you if you directly connect to the server, and not through nginx? Can you give more information? I can't tell too much from the two lines in the bug description.
It works well without nginx, it's an issue with nginx support I think Also, it's the same error if put behind Cloudflare CDN
My code:
// use h2conn for duplex tunnel
ctx, cancel = context.WithCancel(context.Background())
h2 := h2conn.Client{Client: HTTPClient}
conn, resp, err = h2.Connect(ctx, url)
if err != nil {
log.Printf("Initiate conn: %s", err)
return
}
Additional info: nginx returns code 408:
A 408 Request Timeout response code indicates that the server did not receive a complete request from the client within a specific period of time tracked by the server (i.e. the timeout period).
Did you configure nginx to support http2?
Yes, http2 is enabled, and normal requests via HTTP2 work fine
Sorry, it will be very hard for me to debug this. Please look at nginx logs, or use tcpdump/wireshark to debug the connection. If you find anything there it will be very interesting, and see if we can work on a fix to the library.
@jm33-m0 Have you found out the solution? If not, can you post your nginx configuration and output of curl -I -L https://your_domain?
I encapsulated the HTTP2 connection in a proxy, didn't try to solve the nginx (or any kind of reverse proxy) support.