Nginx 配置支持 HTTP/3

问题描述 投票:0回答:1

我正在尝试为我的网站配置 HTTP/3 https://jscoder.io。我在服务器上安装了Nginx v1.25,conf文件是:

root@localhost:~# cat /etc/nginx/conf.d/jscoder.io.conf 
server {
    listen 443 quic reuseport;
    listen 443 ssl;
    server_name jscoder.io;
    ssl_certificate /root/jscoder_io.crt;
    ssl_certificate_key /root/jscoder-ssl.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    quic_retry on;
    ssl_early_data on;

    location / {
        add_header Alt-Svc 'h3=":$server_port"; ma=86400';
        add_header X-protocol $server_protocol always;
        add_header Strict-Transport-Security max-age=15768000;
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

现在 https://http3check.net/?host=https%3A%2F%2Fjscoder.io 表示启用了 HTTP/3。我本地的 macOS FireFox 也显示 H3。此外,如果我访问 H3 测试页面https://quic.nginx.org/,它会为我提供 H3。但 macOS Chrome (v119) 和 Safari 仍然显示 HTTP/1.1(在开发工具“网络”选项卡上)。

我已在 Chrome 上启用快速功能并重新启动浏览器。但运气不佳:

根据https://stackoverflow.com/a/71277536/978320

由于HTTP/3还是一个比较新的协议,浏览器可能会首先使用 连接到服务器时的 HTTP/1 或 HTTP/2。服务器可能会发布广告 支持 HTTP/3 进行后续连接。然而,即使之后 多个请求,如果 QUIC,浏览器最终可能会使用 HTTP/2 和 TCP 由于某种原因握手被延迟。

也许是因为我需要配置 Nginx 对所有请求强制执行 HTTP/3?

nginx http2 quic http3
1个回答
0
投票

由于某种原因,Google Chrome 错误地编写了协议。 例如,Google Chrome 中的 YouTube 可以在 http3 上运行,尽管它显示的是 http2。 我在这里检查了我的网站https://http3check.net/ 您还需要打开 http3 端口。 它们取决于您的案例 86400 中的设置。

© www.soinside.com 2019 - 2024. All rights reserved.