NGINX BoringSSl HTTP3 ERR_CONNECTION_REFUSED

NGINX BoringSSl HTTP3 ERR_CONNECTION_REFUSED

ERR_CONNECTION_REFUSEDNginx 1.25.3 + BoringSSL을 통해 HTTP/3를 활용하려고 시도하는 동안 Google Chrome v.120에서 오류가 발생합니다. nginx-debug가 켜져 있는 동안에는 오류가 없으며 디버그 메시지도 로그에서 발견되지 않습니다. http2는 이 구성과 잘 작동하며https://cloudflare-quic.com/브라우저에서 HTTP/3을 사용할 수 있다고 말합니다.

/etc/nginx/nginx.conf:

user  www-data;
worker_processes  1;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile       on;
    tcp_nopush     on;
    tcp_nodelay    on;
    types_hash_max_size 2048;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    

    ##
    # Access/Error Log Settings
    ##

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    error_log /var/log/nginx/error.log;

    ##
    # SSL Configuration
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;


    ##
    # FastCGI Cache Settings
    ##

    fastcgi_cache_path /etc/nginx-cache levels=1:2 keys_zone=phpcache:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_ignore_headers Cache-Control Expires;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-enabled/website.conf:

server {
  server_name website.site;

  root /var/www/website/public_html/develop;
  index index.html;

  listen 443 quic reuseport;
  listen 443 ssl;

  http2 on;
  http3 on;

  quic_retry on;
  ssl_early_data on;

  add_header alt-svc 'h3=":443"; quic=":443"; ma=2592000;';

  ssl_protocols TLSv1.3;  

  ssl_certificate /etc/ssl/website.site.pem;
  ssl_certificate_key /etc/ssl/website.site-key.pem;
}

UPD:내가 발견한 또 다른 흥미로운 동작은 연결이 사용 가능한 다른 nginx 가상 호스트로 리디렉션된다는 것입니다(quiche 서비스가 사용되는 경우 청취가 무시되는 것처럼 보입니다).

내 솔루션:문제는 인증서가 공개적으로 신뢰할 수 없는 경우 Google Chrome이 HTTP/3 프로토콜로 전환하지 않는다는 것이었습니다(해결책을 찾았습니다).여기). 그럼에도 불구하고 여기에 설명된 가능한 원인은 다른 오류를 해결하는 데 도움이 됩니다.

답변1

웹 브라우저는 먼저 http/1 또는 http/2 연결을 설정합니다. 따라서 2개의 Listen 지시문을 유지해야 합니다. 주석을 제거해야 합니다:

    # listen 443 ssl http2;

다음으로 교체:

    listen 443 ssl;
    http2 on;

Listen 지시문에서는 http2가 더 이상 허용되지 않습니다. 이는 기본적으로 비활성화된 새로운 지시문입니다.https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2

Syntax: http2 on | off;
Default:    
http2 off;
Context:    http, server
This directive appeared in version 1.25.1.

그리고https://nginx.org/en/docs/http/ngx_http_core_module.html#listen

"The parameter is deprecated, the http2 directive should be used instead."

다음 작업 예제도 참조하세요.https://nginx.org/en/docs/quic.html#example

http {
    log_format quic '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" "$http3"';

    access_log logs/access.log quic;

    server {
        # for better compatibility it's recommended
        # to use the same port for quic and https
        listen 8443 quic reuseport;
        listen 8443 ssl;

        ssl_certificate     certs/example.com.crt;
        ssl_certificate_key certs/example.com.key;

        location / {
            # required for browsers to direct them to quic port
            add_header Alt-Svc 'h3=":8443"; ma=86400';
        }
    }
}

답변2

예시 구성을 찾았는데 가상 호스트에 더 많은 것들이 필요합니다

server{
    listen 443 http3 quic reuseport;
    listen 443 ssl http2;

    quic_retry on;
    ssl_early_data on;

    http3_max_field_size 5000;
    http3_max_table_capacity 50;
    http3_max_blocked_streams 30;
    http3_max_concurrent_pushes 30;
    http3_push 10;
    http3_push_preload on;

    add_header alt-svc '$quic=":443"; ma=3600';
index index.html index.nginx-debian.html;
    server_name yourdomain.com www.yourdomain.com

    root /var/www/yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
}
server{
    if ($host = http3.codefaq.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;

    server_name yourdomain.com;
    return 404; # managed by Certbot


}

여기를 보아라https://codefaq.org/server/how-to-install-http-3-quic-on-nginx-server-for-ubuntu/#adding-boringssl-and-http3

관련 정보