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

reverse proxy: rewrite requests and responses for websocket over http2 #6567

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

WeidiDeng
Copy link
Member

Supports reverse proxying h2 websockets to backends. Fix 5565.

Requires upstream support, but can be tested with xcaddy build reverse-proxy-h2-websocket --replace golang.org/x/net=github.com/WeidiDeng/net@websocket-http2

@mholt
Copy link
Member

mholt commented Sep 10, 2024

Very neat, nice work @WeidiDeng 💯

@bt90
Copy link
Contributor

bt90 commented Sep 29, 2024

I'm not 100% sure but a regular HTTP/2 GET request should contain the new setting parameter as outlined in RFC8441 Section 3?

[0-0] == Info: [HTTP/2] [0] ingress: read 45 bytes
[0-0] == Info: [HTTP/2] [0] <- FRAME[SETTINGS, len=36]
[0-0] == Info: [HTTP/2] [0] MAX_CONCURRENT_STREAMS: 250
[0-0] == Info: [HTTP/2] [0] ENABLE_PUSH: TRUE
[0-0] == Info: [HTTP/2] [0] notify MAX_CONCURRENT_STREAMS: 250
[0-0] == Info: [HTTP/2] [0] -> FRAME[SETTINGS, len=18]
[0-0] == Info: [HTTP/2] [0] -> FRAME[SETTINGS, ack=1]
[0-0] == Info: [HTTP/2] [0] -> FRAME[WINDOW_UPDATE, incr=1048510465]
[0-0] => Send SSL data, 5 bytes (0x5)
0000: 17 03 03 00 5a                                  ....Z
[0-0] => Send SSL data, 1 bytes (0x1)
0000: 17                                              .
[0-0] == Info: [HTTP/2] [0] egress: wrote 73 bytes
[0-0] == Info: [HTTP/2] cf_connect() -> 0, 1,
[0-0] == Info: using HTTP/2
[0-0] == Info: [HTTP/2] [1] OPENED stream for https://xxxxxxx.xxx/

Tested via curl:

curl --trace request.dump --trace-config http/2 https://example.com

@WeidiDeng
Copy link
Member Author

i'm not sure about curl debug dump. But I tested this with my Chrome and it works. The setting frame is send at the start of a new http2 connection, so it's sent regardless of the method client uses.

Even without my patch, golang http2 sends the following settings:

image

The output doesn't list all of them.

@bt90
Copy link
Contributor

bt90 commented Oct 5, 2024

Successfully tested in Firefox 👍

Bildschirmfoto vom 2024-10-05 11-38-26

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

Successfully merging this pull request may close these issues.

Support WebSockets over HTTP/2 (RFC8441)
3 participants