全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2356|回复: 14

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

[复制链接]
发表于 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'
复制代码

发表于 2023-5-22 14:55:20 来自手机 | 显示全部楼层
好!支持大佬
发表于 2023-5-22 15:03:18 | 显示全部楼层
支持大佬。quic是不是还不支持ssl_preread?
 楼主| 发表于 2023-5-22 15:17:04 | 显示全部楼层
本帖最后由 dvbhack 于 2023-5-22 15:19 编辑
diocat 发表于 2023-5-22 15:03
支持大佬。quic是不是还不支持ssl_preread?


ssl_prepead 是用于 stream 的吧?

我没试过在 stream 中使用 quic,你可以试试看。我编译的参数是加入了 "-with-stream_ssl_preread_module" 这个选项的。
发表于 2023-5-22 15:28:41 | 显示全部楼层
dvbhack 发表于 2023-5-22 15:17
ssl_prepead 是用于 stream 的吧?

我没试过在 stream 中使用 quic,你可以试试看。我编译的参数是加入 ...


是的。之前我编的版本加入了module,但是quic下配置ssl_preread on 就直接nginx -t报错,现在不知道行不行
 楼主| 发表于 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:*
复制代码


看起来没有什么问题。
发表于 2023-5-22 15:49:44 | 显示全部楼层
支持大佬 zsbd
 楼主| 发表于 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
发表于 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;
        }


试试把这个配置删了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 19:37 , Processed in 0.112699 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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