当前位置: 首页 > news >正文

centos8构建nginx1.27.1+BoringSSL+http3+lua+openresty

需要接入http3,索性最新的nginx在构建一波,趟一遍坑

准备工作

1.环境命令安装

yum install GeoIP -y
yum install GeoIP-devel -y
yum install libmaxminddb-devel -y
yum install -y patch wget zlib zlib-devel lftp gcc gcc-c++ make openssl-devel pcre-devel pcre net-tools yum-utils && yum clean all

2.最新nginx包下载
官方下载

在这里插入图片描述
3.准备boringssl
官网

# 下载使用git
git clone https://boringssl.googlesource.com/boringssl

4.准备ninja 用于构建boringssl
ninja-github-releases

unzip xx.zip
cp ./ninja /usr/bin

5.lua环境构建(可选)
需要以下这些包-可以在github下载相应的包
luajit2
lua-resty-core
lua-resty-lrucache

cd /opt/luajit2-2.1-20240815
make PREFIX=/usr/local/ && make install PREFIX=/usr/local/cd /opt/lua-resty-core-0.1.29
make install LUA_LIB_DIR=/usr/local/share/lua/5.1cd /opt/lua-resty-lrucache-0.14
make install LUA_LIB_DIR=/usr/local/share/lua/5.1#设置环境变量
LUAJIT_INC=/usr/local/include/luajit-2.1
LUAJIT_LIB=/usr/local/lib#构建映射
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/
ln -s /usr/local/openresty/lualib /usr/local/lib/lua
ln -s /usr/local/openresty/lualib/resty /usr/local/lib

6.正向代理(可选)
使用ngx_http_proxy_connect_module 需要先安装补丁

patch -p1 </opt/ngx_http_proxy_connect_module-0.0.7/patch/proxy_connect_rewrite_102101.patch

编译nginx

cd /opt/nginx-1.27.1
./configure --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=nginx --group=nginx --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_v3_module --with-cc=c++ --with-cc-opt="-I/opt/boringssl/include -x c"  --with-ld-opt="-L/opt/boringssl/build/ssl -L/opt/boringssl/build/crypto" --with-http_ssl_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_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --add-module=/opt/lua-nginx-module-0.10.27 --add-module=/opt/ngx-fancyindex-0.5.2 --add-module=/opt/ngx_devel_kit-0.3.1 --with-http_geoip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/opt/ngx_http_geoip2_module-3.4 --add-module=/opt/ngx_http_proxy_connect_module-0.0.7 && make && make install

参数说明:

模块名称简要说明
--with-compat使编译的 Nginx 二进制文件与动态加载模块兼容。
--with-file-aio启用文件异步 I/O 支持,提高文件读写性能。
--with-threads启用多线程支持,提高并发处理能力。
--with-http_addition_module允许在 HTTP 响应的某些部分添加文本。
--with-http_auth_request_module允许将子请求的结果用作访问控制的基础。
--with-http_dav_module启用 WebDAV 方法支持,如 PUT、DELETE 等。
--with-http_flv_module允许对 FLV 视频文件进行时间戳定位。
--with-http_gunzip_module解压缩使用 gzip 压缩的响应。
--with-http_gzip_static_module提供预压缩的 gzip 文件,提高响应速度。
--with-http_v3_module启用 HTTP/3 协议支持。
--with-cc=c++指定使用 C++ 编译器。
--with-http_ssl_module启用 SSL/TLS 支持,允许 HTTPS 连接。
--with-http_mp4_module允许对 MP4 视频文件进行时间戳定位。
--with-http_random_index_module随机选择目录中的文件作为索引文件。
--with-http_realip_module允许从代理服务器或负载均衡器获取真实客户端 IP 地址。
--with-http_secure_link_module提供基于 URL 的安全链接功能。
--with-http_slice_module支持将大文件切片传输,提高大文件传输效率。
--with-http_stub_status_module提供 Nginx 的运行状态信息。
--with-http_sub_module允许在 HTTP 响应中进行文本替换。
--with-http_v2_module启用 HTTP/2 协议支持。
--with-mail启用邮件代理模块,支持 SMTP/IMAP/POP3 协议。
--with-mail_ssl_module为邮件代理模块启用 SSL/TLS 支持。
--with-stream启用流处理模块,支持 TCP/UDP 流量代理。
--with-stream_realip_module允许从代理服务器或负载均衡器获取真实客户端 IP 地址(用于流处理)。
--with-stream_ssl_module启用流处理模块的 SSL/TTLS 支持。
--with-stream_ssl_preread_module允许在 SSL 握手之前读取客户端的协议。
--with-http_geoip_module允许基于 GeoIP 数据库进行地理位置访问控制。
--add-module=/opt/lua-nginx-module-0.10.27添加 Lua 支持,使 Nginx 可以运行 Lua 脚本。
--add-module=/opt/ngx-fancyindex-0.5.2提供美观的目录列表功能。
--add-module=/opt/ngx_devel_kit-0.3.1提供开发工具包,扩展 Nginx 的功能。
--add-module=/opt/ngx_http_geoip2_module-3.4允许基于 GeoIP2 数据库进行地理位置访问控制。
--add-module=/opt/ngx_http_proxy_connect_module-0.0.7允许处理 HTTP CONNECT 方法,用于代理 HTTPS 和其他 TCP 流量。

nginx中的ssl配置增加 quic关键字

server {listen 80;listen 443 ssl;listen 443 quic;http2 on;http3 on;http3_hq on;quic_retry on;ssl_early_data on;quic_gso on;add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443"; h3-25=":443"; h3-23=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"';}

可以使用https://www.http3check.net 检查网站是否启用http3
在这里插入图片描述

问题

1.未找到ssl library

checking for getaddrinfo() ... found
checking for PCRE2 library ... not found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... not found
checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found
auto/configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

解决办法:
需要注意引入动态库时,需要通过增加–with-cc=c++ 且同时在cc-opt 中需要通过-x c 指定为C语言

--with-cc=c++ -with-cc-opt="-I/opt/boringssl/include -x c"  --with-ld-opt="-L/opt/boringssl/build/ssl -L/opt/boringssl/build/crypto"

NGINX + BoringSSL build error (NGINX 1.25.4 required Openssl)
也给出了不同系统解决的办法
在这里插入图片描述

如果docker中使用nginx 需要注意映射端口放行tcp

附件

涉及到的部分附件 有需要的可以csdn下载

参考文档

nginx官方quic说明

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • STM32——看门狗通俗解析
  • Django日志
  • WebRTC服务器搭建
  • SpringBoot + Vue + ElementUI 实现 el-table 分页功能详解
  • 【信号】SIGCHLD信号--了解
  • error: subprocess-exited-with-error
  • 【数据库】MySQL聚合统计
  • 【vuetify】v-select 无法正常显示,踩坑记录!
  • Vue3生命周期钩子函数(Vue3生命周期)
  • vue3 一次二次封装element-plus组件引发的思考
  • 解决ubuntu 24.04 ibus出现卡死、高延迟问题
  • 解决uniapp视频video组件进入全屏再退出全屏后,cover-view失效的问题
  • Brave编译指南2024 Windows篇:拉取Brave源码(六)
  • SpringSecurity剖析
  • yjs04——matplotlib的使用(多个坐标图)
  • 【node学习】协程
  • C# 免费离线人脸识别 2.0 Demo
  • CSS盒模型深入
  • IE报vuex requires a Promise polyfill in this browser问题解决
  • Java面向对象及其三大特征
  • Redux 中间件分析
  • SegmentFault 2015 Top Rank
  • vue2.0开发聊天程序(四) 完整体验一次Vue开发(下)
  • 欢迎参加第二届中国游戏开发者大会
  • 基于OpenResty的Lua Web框架lor0.0.2预览版发布
  • 让你的分享飞起来——极光推出社会化分享组件
  • 推荐一款sublime text 3 支持JSX和es201x 代码格式化的插件
  • 06-01 点餐小程序前台界面搭建
  • 仓管云——企业云erp功能有哪些?
  • #QT(一种朴素的计算器实现方法)
  • (4)logging(日志模块)
  • (CVPRW,2024)可学习的提示:遥感领域小样本语义分割
  • (done) NLP “bag-of-words“ 方法 (带有二元分类和多元分类两个例子)词袋模型、BoW
  • (南京观海微电子)——I3C协议介绍
  • (四)【Jmeter】 JMeter的界面布局与组件概述
  • (万字长文)Spring的核心知识尽揽其中
  • (心得)获取一个数二进制序列中所有的偶数位和奇数位, 分别输出二进制序列。
  • .form文件_一篇文章学会文件上传
  • .Net Attribute详解(上)-Attribute本质以及一个简单示例
  • .netcore 6.0/7.0项目迁移至.netcore 8.0 注意事项
  • .NET中winform传递参数至Url并获得返回值或文件
  • /var/log/cvslog 太大
  • @angular/cli项目构建--http(2)
  • [ 物联网 ]拟合模型解决传感器数据获取中数据与实际值的误差的补偿方法
  • [ 英语 ] 马斯克抱水槽“入主”推特总部中那句 Let that sink in 到底是什么梗?
  • [000-01-011].第2节:持久层方案的对比
  • [023-2].第2节:SpringBoot中接收参数相关注解
  • [ACP云计算]组件介绍
  • [Bada开发]初步入口函数介绍
  • [BZOJ 1032][JSOI2007]祖码Zuma(区间Dp)
  • [emuch.net]MatrixComputations(7-12)
  • [Flex][问题笔记]TextArea滚动条问题
  • [GDOUCTF 2023]<ez_ze> SSTI 过滤数字 大括号{等
  • [GXYCTF2019]BabyUpload1 -- 题目分析与详解
  • [IE编程] 打开/关闭IE8的光标浏览模式(Caret Browsing)