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

news2024/9/21 14:46:00

需要接入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.1

cd /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说明

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2113988.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

YOLOv5: 从0开始搭建环境进行模型训练

视频链接&#xff1a;YOLOv5&#xff1a; 从0开始搭建环境进行模型训练_哔哩哔哩_bilibili 《YOLOv5&#xff1a;从0开始搭建环境进行模型训练》课程致力于帮助学生实战YOLOv5目标检测算法。常心老师将手把手带领大家从0开始搭建YOLOv5环境&#xff0c;带领大家排坑、避坑、填…

windows 环境下搭建mysql cluster 集群详细步骤

1、环境准备 下载mysql集群版本&#xff0c;我这里下载的是mysql-cluster-8.0.39-winx64 https://dev.mysql.com/downloads/cluster/ 2、创建配置文件 mysql集群版本下载以后解压后目录如下&#xff0c;创建配置文件 config.ini(集群配置文件&#xff0c;my.ini mysql配置…

人工智能、机器学习与深度学习的区别及其应用

引言 在过去的十年中,人工智能(AI)从研究实验室走向了工业应用的前沿,成为推动各个行业转型的关键技术。然而,AI 并不仅仅是某一种单一的技术,它包含了多种不同的方法和工具,适用于解决从自动驾驶到医疗诊断等复杂问题。与此同时,行业内对“人工智能”、“机器学习”与…

数据库锁之行级锁、记录锁、间隙锁和临键锁

1. 行级锁 InnoDB 引擎支持行级锁&#xff0c;而MyISAM 引擎不支持行级锁&#xff0c;只支持表级锁。行级锁是基于索引实现的。 对于普通的select语句&#xff0c;是不会加记录锁的&#xff0c;因为它属于快照读&#xff0c;通过在MVCC中的undo log版本链实现。如果要在查询时对…

如何从硬盘恢复已删除/丢失的文件?硬盘恢复已删除的文件技巧

如何从硬盘恢复已删除/丢失的文件&#xff1f;本教程将教您如何使用专业硬盘恢复软件从内置或外置硬盘恢复数据&#xff0c;或不使用软件从硬盘恢复已删除的文件。 “有人知道如何从外部硬盘恢复文件吗&#xff1f;当我将外部硬盘插入计算机时&#xff0c;我错误地删除了一些文…

自动提取上升沿周期时间python

import pandas as pd import numpy as np# 读取你的CSV数据&#xff08;假设数据已经加载到 DataFrame df 中&#xff09; # df pd.read_csv(your_data.csv)# 确保保存时间是datetime类型 df[保存时间] pd.to_datetime(df[保存时间])# 假设喂料电机实时转速的列名为 喂料电机…

828华为云征文|基于Flexus云服务器X实例的应用场景-拥有一款自己的ssl监控工具

先看这里 写在前面效果图华为云Flexus云服务器X实例介绍特点可选配置购买 连接服务器Uptime-kuma简介开源信息部署准备工作&#xff1a;docker部署命令访问uptime-kuma 基本配置总结 写在前面 作为一个个人开发者&#xff0c;相信你手里肯定也有不少自己的服务&#xff0c;有的…

【Linux修行路】线程安全和死锁

目录 ⛳️推荐 一、线程安全 1.1 常见的线程不安全情况 1.2 常见的线程安全情况 1.3 常见的不可重入情况 1.4 常见可重入的情况 1.5 可重入与线程安全的联系 1.6 可重入与线程安全的区别 二、死锁 2.1 死锁的四个必要条件 2.2 如何避免产生死锁&#xff1f; ⛳️推荐…

Mysql高级教程

1.安装部署 安装依赖性&#xff1a; [rootmysql-node10 ~]# dnf install cmake gcc-c openssl-devel ncurses-devel.x86_64 libtirpc-devel-1.3.3-8.el7_4.x86_64.rpm rpcgen.x86_64 下载并解压源码包 [rootmysql-node10 ~]# tar zxf mysql-boost-5.7.44.tar.gz [rootmysql-no…

SpringSecurity原理解析(一)

一、SpringSecurity 核心组件 在SpringSecurity中的jar包有4个&#xff0c;作用分别为&#xff1a; spring-security-coreSpringSecurity的核心jar包&#xff0c;认证和授权的核心代码都在这里面spring-security-config如果使用Spring Security XML名称空间进行配置或Spring S…

营业执照贷款揭秘,不只是有证那么简单!

聊到营业执照贷款&#xff0c;不少人误以为手里有证就能秒到账&#xff0c;这其实是个误区。正经说&#xff0c;这是经营性贷款&#xff0c;放款速度可不是“一刀切”。快的话&#xff0c;一天搞定&#xff1b;慢的呢&#xff0c;三五天到半个月不等&#xff0c;全看你的条件和…

materail3 CircularProgressIndicator和LinearProgressIndicator有难看的白块和断点

看看&#xff0c;就是这个垃圾效果&#xff1a; 圆圈的进度条有断点&#xff0c;不连接&#xff1b; 横线进度条&#xff0c;有尾部亮色&#xff0c;进度处又有分割。 它的原出处在这里&#xff1a;https://m3.material.io/components/progress-indicators/overview&#xff0…

CSP-J基础之cmath常见函数

文章目录 前言1. **sin 函数**2. **cos 函数**3. **exp 函数**4. **log 函数**5. **fabs 函数**6. **pow 函数**7. **sqrt 函数**8. **ceil 函数**9. **floor 函数** 总结 前言 在计算机科学与编程中&#xff0c;数学函数是解决各种计算问题的基础工具。C标准库中的 cmath 头文…

【Qt】处理键盘事件

处理键盘事件 要想获取到用户的键盘按键&#xff0c;在之前的学习中使用过QShortCut&#xff0c;这个函数是信号槽机制封装过获取键盘按键的方式&#xff0c;站在更底层的角度&#xff0c;也可以通过事件获取到当前用户键盘按下的情况。 Qt 中的按键事件是通过 QKeyEvent 类来实…

【Nacos】负载均衡

生产环境相对是比较恶劣的,我们需要对服务的流量进行更加精细的控制.Nacos支持多种负载均衡策略,包括权重,同机房,同地域,同环境等. 1. 服务下线 当某一个节点上接口的性能较差时,我们可以第一时间对该节点进行下线. 操作步骤: 服务详情 ->下线 当点击下线后&#xff0c;…

HarmonyOS】ArkTS学习之基于TextTimer的简易计时器的elapsedTime最小时间单位问题

本文旨在纪录自己对TextTimer使用过程的疑惑问题 我在查看教程时候&#xff0c;发现很多博客在onTimer(event: (utc: number, elapsedTime: number) > void) 这里提到elapsedTime&#xff1a;计时器经过的时间&#xff0c;单位为毫秒。我不清楚是否为版本问题。 在我查看ver…

Linux 进程创建

进程串 #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> int main(){int p1,p2,p3,p4;while((p1fork())-1);if(p10){printf("child %d parent %d\n",getpid(),getppid());while((p2fork())-1);if(p20)…

[C++#33][异常] 错误码 | 抛出与捕获 | 异常安全 | 异常体系

目录 C语言与C错误处理方式的对比及应用 一、C语言传统的错误处理方式 1. 终止程序&#xff1a;assert 2. 返回错误码 缺点&#xff1a; 二、C中的异常处理机制 1. 基本概念 2. 异常的抛出与捕获 3. 异常的重新抛出 三、C中的异常安全 1. 构造函数与析构函数的异常 …

数字图像噪声常用的概率分布

高斯、瑞利、指数、埃尔朗分布都是指数家族分布。 注&#xff1a;冈萨雷斯的四版都是错的。 禹晶、肖创柏、廖庆敏《数字图像处理&#xff08;面向新工科的电工电子信息基础课程系列教材&#xff09;》 禹晶、肖创柏、廖庆敏《数字图像处理》资源二维码

KDD 2024 时空数据(Spatio-temporal) ADS论文总结

2024 KDD&#xff08; ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 知识发现和数据挖掘会议&#xff09;在2024年8月25日-29日在西班牙巴塞罗那举行。 本文总结了KDD2024有关时空数据(Spatial-temporal) 的相关论文&#xff0c;如有疏漏&#xff0c;欢迎大…