-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Serve http2 when listener wrapper doesn't return *tls.Conn #4929
Conversation
Thanks for working on this! So, my understanding of this is, that it allows us to serve HTTP/2 even if the underlying Conn is wrapped by a ListenerWrapper plugin so that if it's not a tls.Conn, it can still be recognized as one? |
Yes, because golang http.server won't directly serve http2 when return non tls.Conn, I have to manually configure h2server. tls.Conn still uses http.Server code path, because when handshake is not complete, it won't have "h2" as negotiated protocol. |
423dea2
to
f4cb346
Compare
@mholt I noticed you don't allow serve only http2, if you want, I can use http2.Server.ServeConn in this case. |
@WeidiDeng Yeah, we'd have to write our own HTTP server. I'm not sure I'm quite ready for that since it seems like a maintenance burden. You can see my attempt here: #4707 (comment) I'll review this soon! |
@mholt I looked at you code, that's because http2.Server requires tls handshake to be complete, if there is any. To be fair, http2.Server can serve h2c with prior knowledge, that's like how currently reverse_proxy h2c transport is implemented. But yes I agree it's a burden, especially if we are allowing serve http2 with non tls.Conn. Perhaps it's easier to configure tls nextproto directly, normal clients won't send h1 requests on a h2 tls.Conn. |
# Conflicts: # modules/caddyhttp/app.go # modules/caddyhttp/server.go
@WeidiDeng could you rebase this? I'm not sure there's anything really blocking merging this. Seems like a reasonable fix for a usecase only used by caddy-l4 currently. |
@francislavoie I'll also need to update l4 listener module, that part is left as a todo. There are some parts that I'm not sure, like using x/net/http2 instead of builtin http2, should there be an option? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I made a first pass and have some minor suggestions -- This looks like we're doing a lot more in-house but it opens up some new possibilities, yeah?
74d0160
to
7c8fe21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @WeidiDeng -- let's give this a try. Sorry for the long time on this. Thank you for your work!
fixes 4921