nginx-quic(裸quic lb)使用(未打通)

官方指导见https://www.nginx-cn.net/blog/introducing-technology-preview-nginx-support-for-quic-http-3/

1、代码下载

https://hg.nginx.org/nginx-quic
nginx-quic源码
其中只有quic对应的版本支持–with-stream_quic_module,其他均报不认识(包括stable和其他1.19的)

2、编译

./auto/configure --with-debug --with-stream_quic_module  --with-http_ssl_module --with-stream  --with-cc-opt="-I../boringssl-git/include" --with-ld-opt="-L../boringssl-git/build/ssl -L../boringssl-git/build/crypto"

make install

3、配置

stream {
  server {
        listen 8001 quic reuseport;
        proxy_pass quic_upstreams;
		
		ssl_protocols       TLSv1.2 TLSv1.3;
		ssl_certificate ssl/localhost.pem;
        ssl_certificate_key ssl/localhost-key.pem;	
		
		#add_header alt-svc 'h3-29=":443"; ma=86400';
    }
	
	upstream quic_upstreams {
    #quic_lb_mode ;
    server 127.0.0.1:8443;
    #server 127.0.0.1:8444 sid=127.0.0.1:8444;
}
}

4、启动

./objs/nginx -p . -c conf/nginx.conf

停止:
./objs/nginx -s stop–报错:

bash: ./sbin/nginx: No such file or directory

这个问题可以直接kill(使用ps -ef | grep nginx查找到主进程,然后kill)
也可以使用默认目录启动:

/usr/local/nginx# ./objs/nginx -c conf/nginx.conf
/usr/local/nginx# ./sbin/nginx -s stop

启动参数含义:

# ./objs/nginx -help
nginx version: nginx/1.19.8
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
             [-e filename] [-c filename] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -e filename   : set error log file (default: logs/error.log)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

5、log

config加–with-debug
在nginx-quic下新建logs文件夹,否则报错:

nginx: [alert] could not open error log file: open() "./logs/error.log" failed (2: No such file or directory)

6、gdb

obj/Makefile里在-c后加-g,然后重新make install
运行后ps -ef | grep ngi找到nginx: worker process的进程号,如5652
gdb 5652

7、调试

quic客户端报错:

connect fail:  CRYPTO_ERROR (0x178): TLS alert

logs的error.log中查找错误:

2021/03/19 15:12:46 [debug] 5652#0: *3 quic insert server id seqnum:0 id len:20 6eec62f9579d59730aa195fc796b7d6bc589b9e5
2021/03/19 15:12:46 [debug] 5652#0: *3 quic packet rx clearflags:c1
2021/03/19 15:12:46 [debug] 5652#0: *3 quic packet rx number:0 len:2
2021/03/19 15:12:46 [debug] 5652#0: *3 quic stateless reset token 39872f101e2a17f68052d6cccbe4136d
2021/03/19 15:12:46 [debug] 5652#0: *3 quic stateless reset token 39872f101e2a17f68052d6cccbe4136d
2021/03/19 15:12:46 [debug] 5652#0: *3 posix_memalign: 00007FFFDE575EB0:256 @16
2021/03/19 15:12:46 [debug] 5652#0: *3 quic frame rx init PADDING
2021/03/19 15:12:46 [debug] 5652#0: *3 quic frame rx init CRYPTO len:267 off:0
2021/03/19 15:12:46 [debug] 5652#0: *3 quic SSL_quic_read_level:0 SSL_quic_write_level:0
2021/03/19 15:12:46 [debug] 5652#0: *3 quic ngx_quic_send_alert() lvl:0  alert:120
2021/03/19 15:12:46 [debug] 5652#0: *3 posix_memalign: 00007FFFDE5762F0:256 @16
2021/03/19 15:12:46 [debug] 5652#0: *3 post event 00007FFFDE5748F8
2021/03/19 15:12:46 [debug] 5652#0: *3 quic output init packet max:1252 min:0
2021/03/19 15:12:46 [debug] 5652#0: *3 quic frame tx init CONNECTION_CLOSE err:376 TLS alert ft:0
2021/03/19 15:12:46 [debug] 5652#0: *3 quic packet tx init bytes:14 need_ack:0 number:0 encoded nl:1 trunc:0x0
2021/03/19 15:12:46 [debug] 5652#0: *3 sendmsg: 60 of 60
2021/03/19 15:12:46 [debug] 5652#0: *3 quic lost timer unset
2021/03/19 15:12:46 [debug] 5652#0: *3 quic SSL_quic_read_level:0 SSL_quic_write_level:0
2021/03/19 15:12:46 [debug] 5652#0: *3 SSL_do_handshake: -1
2021/03/19 15:12:46 [debug] 5652#0: *3 SSL_get_error: 1
2021/03/19 15:12:46 [error] 5652#0: *3 SSL_do_handshake() failed (SSL: error:10000133:SSL routines:OPENSSL_internal:NO_APPLICATION_PROTOCOL)
2021/03/19 15:12:46 [debug] 5652#0: *3 quic packet init done decr:1 pn:0 perr:0 rc:-1
2021/03/19 15:12:46 [debug] 5652#0: *3 quic ngx_quic_close_connection rc:-1

wireshark截取报文内容无异常:
quic报文
注:如果wireshark解析失败,可能是版本过低,需要升级,我用的是3.4.3.
然后 编辑->首选项->Protocols->QUIC 填入端口号

附编译问题

collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:741: client] Error 1
server.cc: In function ‘void {anonymous}::config_set_default(Config&)’:
server.cc:3516:10: error: ‘struct Config’ has no member named ‘sid’
 3516 |   config.sid = NULL;
      |          ^~~
server.cc: In function ‘int main(int, char**)’:
server.cc:3914:16: error: ‘struct Config’ has no member named ‘sid’
 3914 |         config.sid = optarg;
      |                ^~~
make[1]: *** [Makefile:784: server.o] Error 1
/mnt/d/linux/code/nginx/quic/ngtcp2/examples/h09client.cc:742: undefined reference to `nghttp3_buf_len'
/usr/bin/ld: h09client.o: in function `Client::submit_http_request(Stream*)':
/mnt/d/linux/code/nginx/quic/ngtcp2/examples/h09client.cc:1670: undefined reference to `nghttp3_buf_init'
/usr/bin/ld: h09client.o: in function `Client::write_streams()':
/mnt/d/linux/code/nginx/quic/ngtcp2/examples/h09client.cc:1187: undefined reference to `nghttp3_buf_len'
/usr/bin/ld: /mnt/d/linux/code/nginx/quic/ngtcp2/examples/h09client.cc:1208: undefined reference to `nghttp3_buf_len'

把编译生成的libnghttp3.so 在代码目录的/build/lib/下面 拷贝到/usr/lib 并建立链接ln -s libnghttp3.so.0.0.0 libnghttp3.so

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值