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

ALPN问题 #1

Open
segfault-bilibili opened this issue Sep 23, 2022 · 0 comments
Open

ALPN问题 #1

segfault-bilibili opened this issue Sep 23, 2022 · 0 comments

Comments

@segfault-bilibili
Copy link
Owner

目前NodeJS好像没有提供类似SNICallback的方式来给每一个连接赋予不同的ALPNProtocols。

所以采取了一个有问题的绕过办法:

  1. 开两个服务器,一个是同时兼容HTTP1的HTTP2服务器,另一个是专用于HTTP1的TLS服务器(设置ALPNProtocols仅为http/1.1)。后者接到请求后,pipe到前者。

  2. 在HTTP CONNECT代理处分流,根据CONNECT里(按理说应该从SNI里读)的主机名去探测服务器是否支持HTTP2,然后把结果记录下来,根据结果来决定要转发给上述哪一个服务器。

但如果CONNECT里没有给主机名、只给了IP地址,那么探测结果就会不正确(因为有些CDN在不给SNI的情况下ALPN返回支持HTTP2,而给SNI的情况下有些网站返回的是只支持HTTP1不支持HTTP2,最后结果就是误以为支持HTTP2而实际上不支持)。

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