ubuntu Nginx 1.25.2 HTTP/3在CURL上工作,但不适用于任何浏览器

whhtz7ly  于 8个月前  发布在  Nginx
关注(0)|答案(1)|浏览(71)

我尝试在Ubuntu 22.04上配置nginx 1.25.2支持HTTP/3。我使用BoringSSL库构建它。但是当我尝试使用浏览器连接到我的服务器时,我没有得到任何东西。(例如Firefox中的“无法连接”和Chrome中的“无法访问此站点”)。
下面是nginx -V输出:

built with OpenSSL 1.1.1 (compatible; BoringSSL) (running with BoringSSL) 
TLS SNI support enabled configure arguments: 
--prefix=/etc/nginx --with-http_ssl_module --with-http_v2_module --with-debug 
--with-http_v3_module --with-cc-opt=-I../boringssl/include 
--with-ld-opt='-L../boringssl/build/ssl -L../boringssl/build/crypto'

字符串
下面是我在nginx.conf中的服务器部分:

server {
        #listen 443 ssl 
        #http2 on;
        listen 443 quic reuseport;
        server_name  example_myserver;
        ssl_certificate cert.pem;
        ssl_certificate_key key.pem;
        ssl_protocols TLSv1.3;
        location / {
            add_header Alt-Svc 'h3=":443"; ma=86400';
            root   html;
            index  index.html index.htm;
        }


使用上面的配置,我可以使用http 3 curl获得HTTP/3响应:

HTTP/3 200 
server: nginx/1.25.2
date: Wed, 23 Aug 2023 08:12:55 GMT
content-type: text/html
content-length: 615
last-modified: Tue, 22 Aug 2023 14:25:41 GMT
etag: "64e4c565-267"
alt-svc: h3=":443"; ma=86400
accept-ranges: bytes


使用https://github.com/cloudflare/quiche http 3client工具,我得到了这个:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>


但是当我通过浏览器到达同一个服务器时,那里什么都没有(Firefox中的“无法连接”和Chrome中的“无法到达该网站”)。UFW完全关闭。顺便说一下,http 1http 2工作没有任何问题。也许有人有类似的问题,可以帮助我,或者我错过了什么?我将非常感谢任何有用的信息。

xytpbqjk

xytpbqjk1#

看来我们遇到了同样的情况。
结论:如果您使用浏览器,您的服务器将被要求具有有效的证书。
我的nginx版本

❯ /opt/nginx-1.25.2/sbin/nginx -V
nginx version: nginx/1.25.2
built by gcc 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) 
built with OpenSSL 1.1.1 (compatible; BoringSSL) (running with BoringSSL)
TLS SNI support enabled
configure arguments: 
--prefix=/opt/nginx-1.25.2 
--with-debug 
--with-http_v3_module 
--with-http_v2_module 
--with-http_ssl_module 
--with-http_realip_module 
--with-http_gzip_static_module 
--with-http_gunzip_module 
--with-http_slice_module 
--with-stream 
--with-stream_ssl_module 
--with-stream_ssl_preread_module 
--with-stream_realip_module 
--with-compat 
--with-threads 
--with-file-aio 
--with-http_stub_status_module 
--with-cc-opt=-I../boringssl/include 
--with-ld-opt='-L../boringssl/build/ssl -L../boringssl/build/crypto'

字符串
nginx.conf中的服务器部分

server {
        #listen       80;
        #listen       8443 ssl;
        listen       443 ssl;
        listen       [::]:443 ssl;
        listen       443 quic;
        listen       [::]:443 quic;

        server_name  example_myserver;

        ssl_certificate     server.crt;
        ssl_certificate_key server.key;
        ssl_protocols       TLSv1.3;
        ssl_session_timeout 5m;

        root   /home/www/;
        index  index.html index.htm;

        location / {

            add_header Alt-Svc 'h3=":443"; ma=86400';
            add_header x-quic 'h3';
        }


当我尝试bilibili/quiche时,我添加了param --disable_certificate_verification=true,这意味着只需跳过SSL检查,并且它一直有效。

./simple_quic_client \
  --disable_certificate_verification=true \
  --host=127.0.0.1 --port=443 \
  "https://www.example.org/index.html"


我猜可能是SSL的问题吧?还记得系统中的CA链吗?
参考:希望能帮助你解决这个问题。
[1][https://github.com/bilibili/quiche/](https://github.com/bilibili/quiche/)
[2][https://bagder.github.io/HTTP3-test/](https://bagder.github.io/HTTP3-test/)的
对于[2],事实证明,并不是每个网站都能在浏览器中工作。令人惊讶的是。。但仍然有点困惑?
祝你今天过得愉快。
顺便说一句,不幸的是,我无法编译与http 3支持的 curl 。如果你能展示它是如何工作的,告诉我该死的正确的方法,我会很感激。
我的卷发版本

./curl --version                                               ✘  23:25:51 
curl 8.4.1-DEV (x86_64-pc-linux-gnu) libcurl/8.4.1-DEV OpenSSL/3.0.10 zlib/1.2.11 brotli/1.0.9 ngtcp2/0.19.1 nghttp3/0.15.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTP3 HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSocket


看起来我成功了,但是

./curl --http3-only https://quic.rocks:4433/                     ✔  23:25:55 
curl: (3) HTTP/3 is not supported over a HTTP proxy


感谢上帝!

相关问题