全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2392|回复: 14
打印 上一主题 下一主题

【分享】Debian 12 的 nginx-quic deb 包(AMD64+ARM64)

[复制链接]
跳转到指定楼层
1#
发表于 2023-5-22 14:51:43 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
本帖最后由 dvbhack 于 2023-5-22 15:28 编辑

Debian 12 即将于 2023年06月30日发布,目前我暂时升级了 AMD64 和 ARM64 各一台进行前期准备,为之后把所有机器升级到 Debian 12 做准备。

升级的过程中发现 Nginx 官方源还没有提供 Debian 12 的支持,当然,我的 NGINX 也正好一直都是做单独编译后打包 deb 复用的。

这次做完顺手分享一下吧。虽然有需求的 mjj 应该是少数(大部分都会选择自己编译、官方源安装、宝塔和一键脚本)。

deb 下载地址:https://www.aliyundrive.com/s/gerPBhs4NPe

包是可以下载到本机进行解压查看的,如果想使用又担心的,可以先下载到本地解压缩,就能看到这个 deb 包安装时执行的全部命令和向你的系统添加的文件。

安装步骤:

- 先安装依赖项
  1. apt install libjemalloc2
复制代码

- 安装 nginx:
  1. dpkg -i nginx-quic_1.25.0_....deb
复制代码


=====

编译说明:

  • 采用 nginx 官方的 nginx-quic 分支(1.25.0),cloudflare 的优化版 zlib,google 的 boringssl(为了支持 quic、http3),pcre2
  • 编译了 image-filter 模块、geoip 模块、njs 模块(支持 nginx 配置文件中使用 javascript,看官方文档)、xslt_filter 模块 为动态模块,可以按需加载
  • 添加了 google 提供的 brotli 模块、openresty 开发的 headers-more 模块为内置模块
  • 增加了 ssl.conf、proxy.conf、fastcgi.conf 和 map.conf 几个常见的配置代码块,减少配置时的重复代码


编译参数:

  1. nginx version: nginx/1.25.0
  2. built by gcc 12.2.0 (Debian 12.2.0-14)
  3. built with OpenSSL 1.1.1 (compatible; BoringSSL) (running with BoringSSL)
  4. TLS SNI support enabled
  5. configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp--http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=www --group=www --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-stream_geoip_module=dynamic --add-dynamic-module=../njs/nginx --add-module=../ngx-brotli --add-module=../ngx-headers-more --with-http_v3_module --with-pcre --with-pcre=../pcre2 --with-pcre-jit --with-zlib=../cf-zlib --with-zlib-opt='-O2 -march=native -fPIC -I/usr/local/src/boringssl/.openssl/include/' --with-zlib-asm=arm64 --with-openssl=../boringssl --with-openssl-opt='enable-tls1_3 enable-ec_nistp_64_gcc_128' --with-cc-opt='-g0 -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -march=native -pipe -flto -funsafe-math-optimizations --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DTCP_FASTOPEN=23 -I/usr/local/src/boringssl/.openssl/include/' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC -L/usr/local/src/boringssl/.openssl/lib/ -ljemalloc'
复制代码

15#
 楼主| 发表于 2023-5-22 16:42:46 | 只看该作者
奧巴马 发表于 2023-5-22 16:18
我用的1.23版本.刚编译了一下,发现没有--with-stream_quic_module这个选项了.去除后编译.

listen 443 ht ...

https://hg.nginx.org/nginx-quic/rev/69bae2437d74

这个配置项废弃了
14#
发表于 2023-5-22 16:18:32 | 只看该作者
本帖最后由 奧巴马 于 2023-5-22 16:25 编辑
dvbhack 发表于 2023-5-22 16:03
nginx-quic 分支,hg clone 下来,编译好之后 nginx -V 显示的版本号就是 1.25.0


我用的1.23版本.刚编译了一下,发现没有--with-stream_quic_module这个选项了.去除后编译.

listen 443 http3 quic reuseport;   这个http3开启选项没有了. 是不是新版移除了它?

找到了: https://hg.nginx.org/nginx-quic/rev/c851a2ed5ce8

删除了.更新的话.我所有的nginx配置都得改.
13#
 楼主| 发表于 2023-5-22 16:04:14 | 只看该作者
diocat 发表于 2023-5-22 15:55
试试把这个配置删了

删了之后,nginx -t 和 重启 nginx 都没问题,但是我没有 quic 客户端来做测试,我的 curl 是系统版本,不支持 '--http3' 选项。
12#
 楼主| 发表于 2023-5-22 16:03:02 | 只看该作者
奧巴马 发表于 2023-5-22 15:59
nginx-quic 有1.25了吗?我怎么只看到1.24?

nginx-quic 分支,hg clone 下来,编译好之后 nginx -V 显示的版本号就是 1.25.0
11#
发表于 2023-5-22 15:59:40 | 只看该作者
nginx-quic 有1.25了吗?我怎么只看到1.24?
10#
发表于 2023-5-22 15:55:09 | 只看该作者
本帖最后由 diocat 于 2023-5-22 15:58 编辑
dvbhack 发表于 2023-5-22 15:50
进一步测试,发往 127.0.0.1:8443 的 https 请求,也正确地按照 ssl_preread 的结果,转发到了 github ...

        server {
                listen 8443;
                proxy_pass $name;
                ssl_preread on;
        }


试试把这个配置删了
9#
 楼主| 发表于 2023-5-22 15:50:38 | 只看该作者
diocat 发表于 2023-5-22 15:28
是的。之前我编的版本加入了module,但是quic下配置ssl_preread on 就直接nginx -t报错,现在不知道行不 ...

  1. curl -i -v --alt-svc altsvc.cache https://github.com:8443/ --resolve github.com:8443:127.0.0.1
  2. * Added github.com:8443:127.0.0.1 to DNS cache
  3. * Hostname github.com was found in DNS cache
  4. *   Trying 127.0.0.1:8443...
  5. * Connected to github.com (127.0.0.1) port 8443 (#0)
  6. * ALPN: offers h2,http/1.1
  7. * TLSv1.3 (OUT), TLS handshake, Client hello (1):
  8. *  CAfile: /etc/ssl/certs/ca-certificates.crt
  9. *  CApath: /etc/ssl/certs
  10. * TLSv1.3 (IN), TLS handshake, Server hello (2):
  11. * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
  12. * TLSv1.3 (IN), TLS handshake, Certificate (11):
  13. * TLSv1.3 (IN), TLS handshake, CERT verify (15):
  14. * TLSv1.3 (IN), TLS handshake, Finished (20):
  15. * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
  16. * TLSv1.3 (OUT), TLS handshake, Finished (20):
  17. * SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
  18. * ALPN: server accepted h2
  19. * Server certificate:
  20. *  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
  21. *  start date: Feb 14 00:00:00 2023 GMT
  22. *  expire date: Mar 14 23:59:59 2024 GMT
  23. *  subjectAltName: host "github.com" matched cert's "github.com"
  24. *  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS Hybrid ECC SHA384 2020 CA1
  25. *  SSL certificate verify ok.
  26. * using HTTP/2
  27. * h2h3 [:method: GET]
  28. * h2h3 [:path: /]
  29. * h2h3 [:scheme: https]
  30. * h2h3 [:authority: github.com:8443]
  31. * h2h3 [user-agent: curl/7.88.1]
  32. * h2h3 [accept: */*]
  33. * Using Stream ID: 1 (easy handle 0xaaab010bd9e0)
  34. > GET / HTTP/2
  35. > Host: github.com:8443
  36. > user-agent: curl/7.88.1
  37. > accept: */*
  38. >
  39. * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  40. * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  41. * old SSL session ID is stale, removing
  42. < HTTP/2 301
  43. HTTP/2 301
  44. < content-length: 0
  45. content-length: 0
  46. < location: https://github.com/
  47. location: https://github.com/

  48. <
  49. * Connection #0 to host github.com left intact
复制代码


进一步测试,发往 127.0.0.1:8443 的 https 请求,也正确地按照 ssl_preread 的结果,转发到了 github
8#
发表于 2023-5-22 15:49:44 | 只看该作者
支持大佬 zsbd
7#
 楼主| 发表于 2023-5-22 15:47:17 | 只看该作者
diocat 发表于 2023-5-22 15:28
是的。之前我编的版本加入了module,但是quic下配置ssl_preread on 就直接nginx -t报错,现在不知道行不 ...

  1. stream {
  2.         map $ssl_preread_server_name $name {
  3.                 bitbucket.net bitbucket;
  4.                 gitlab.com gitlab;
  5.                 default github;
  6.         }

  7.         upstream github {
  8.                 server 20.205.243.166:443;
  9.         }

  10.         upstream bitbucket {
  11.                 server 104.192.141.1:443;
  12.         }

  13.         upstream gitlab {
  14.                 server 172.65.251.78:443;
  15.         }

  16.         server {
  17.                 listen 8443;
  18.                 proxy_pass $name;
  19.                 ssl_preread on;
  20.         }

  21.         server {
  22.                 listen 8443 udp;
  23.                 proxy_pass $name;
  24.                 ssl_preread on;
  25.         }
  26. }
复制代码


stream 是4层转发,它只是把指定端口的请求转发给 upstream,对它来说,不需要区分是 http2 还是 http3,顶多区分一下 tcp、udp 吧?

我测试了上面的配置:

  1. $ nginx -t
  2. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  3. nginx: configuration file /etc/nginx/nginx.conf test is successful

  4. $ systemctl restart nginx
  5. $

  6. $ netstat -anl | grep 8443
  7. tcp        0      0 0.0.0.0:8443            0.0.0.0:*               LISTEN
  8. udp        0      0 0.0.0.0:8443            0.0.0.0:*
复制代码


看起来没有什么问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-11 17:14 , Processed in 0.079845 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表