macbre / docker-nginx-http3

Stable and up-to-date root-less nginx with quic + http/3, google brotli compression, njs, GeoIP2, and Grade A+ SSL config
https://hub.docker.com/r/macbre/nginx-http3
161 stars 53 forks source link

There are insufficient support for http3 #81

Closed wordhui closed 2 years ago

wordhui commented 2 years ago

After testing, most platform browsers cannot be accessed using http3

browser platform http3 access
edge-102.0.1245.33 windows no
edge -99.0.1150.55 linux no
firefox-100.0.2 linux no
firefox-101.0 windows yes
chrome-102.0.5005.63 windows no
chrome -100.0.4896.127 linux no

Here are some interesting phenomena

There is no problem with the UDP port of the computer

Below is my https.conf file

server {
    # quic and http/3
    listen 443 http3 reuseport;

    # http/2 and http/1.1
    listen 443 ssl http2;

    server_name localhost;

    # openssl-generated pair for local development
    # https://letsencrypt.org/docs/certificates-for-localhost/
    ssl_certificate     /etc/nginx/ssl/localhost.crt;
    ssl_certificate_key /etc/nginx/ssl/localhost.key;

    # Enable all TLS versions (TLSv1.3 is required for QUIC).
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_protocols TLSv1.3;

    # 0-RTT QUIC connection resumption
    ssl_early_data on;

    # Add Alt-Svc header to negotiate HTTP/3.
    # m=5: Easy to observe HTTP2-HTTP3 switching process
    add_header alt-svc 'h3=":443"; ma=5, h3-27=":443"; ma=5, h3-28=":443"; ma=5,h3-29=":443"; ma=5,h3-Q050=":443"; ma=5,h3-Q046=":443"; ma=5,h3-Q043=":443"; ma=5,quic=":443"; ma=5; v="46,43"';
    # add_header alt-svc 'h3=":443"; h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400';
    add_header QUIC-Status $http3;     # Sent when QUIC was used

    # proxy_set_header Http-Version       $server_protocol;
    location / {
        proxy_pass   https://172.17.0.1:5000;
    }
}
macbre commented 2 years ago

Interestingly, Firefox 100.0 on MacOS works fine:

Screenshot 2022-06-13 at 13 49 39
macbre commented 2 years ago

I believe the issue is in how http3/ is advertised in alt-svc response header.

https://blog.cloudflare.com/ responds with:

alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

However, still Chrome does not switch to http/3 for localhost traffic...

macbre commented 2 years ago

It seem that browsers have some sort of heuristics deciding whether to use http/3 or fall back to h2.

My production site (that uses the latest version of this image) works fine under http/3.

wordhui commented 2 years ago

It seem that browsers have some sort of heuristics deciding whether to use http/3 or fall back to h2.

My production site (that uses the latest version of this image) works fine under http/3.

I use chrome and Firefox under Linux to access your web address. It really runs on http3 Interestingly, Under Windows, chrome uses http2 access and Firefox uses http3 access.

image image image