喜大普奔,前两天发现Nginx竟然自带支持了ACME功能,让我很想测试一下,但是发现手头没有资源让我测试,忽然我想到可以用docker来构建nginx然后测试ACME功能,在这个过程中发现原来官方Nginx镜像并没有集成ACME插件,只有少的可怜的几个插件测试不了acme,这怎么能忍,所以我就想是否能够自行编译第三方插件并加入到新Nginx镜像中,那么话不多说开干!喜欢折腾的朋友也可以加群一起讨论哦!如果无法看到图片可以私信哈!

1.创建Dockerfile

root@wolfan-NUC9V7QNX:~/Docker_Build_image# cat Dockerfile
# 使用 nginx:1.29.1 作为构建基础镜像
FROM nginx:1.29.1 AS build# 安装构建依赖
RUN apt-get update && apt-get install -y --no-install-recommends \build-essential \curl \git \libpcre3-dev \libssl-dev \zlib1g-dev \ca-certificates \libxml2-dev \libxslt1-dev \pkg-config \openssl \build-essential \libtool \libssl-dev \libpcre2-dev \zlib1g-dev \pkg-config \wget \clang \libclang-dev \&& rm -rf /var/lib/apt/lists/*# 安装 Rust 和 Cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y# 设置环境变量
ENV PATH="/root/.cargo/bin:$PATH"# 验证 Rust 和 Cargo 是否安装成功
RUN echo $PATH && ls /root/.cargo/bin && cargo --version# 下载 Nginx 源代码
RUN curl -fSL https://nginx.org/download/nginx-1.29.1.tar.gz -o nginx.tar.gz \&& tar -xzvf nginx.tar.gz \&& cd nginx-1.29.1RUN git clone https://github.com/openresty/echo-nginx-module.git /tmp/echo-nginx-module \&& git clone https://github.com/vozlt/nginx-module-vts.git /tmp/nginx-module-vts \&& git clone https://github.com/openresty/rds-json-nginx-module.git /tmp/rds-json-nginx-module \&& git clone https://github.com/openresty/memc-nginx-module.git /tmp/memc-nginx-module \&& git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git /tmp/ngx_http_substitutions_filter_module \&& git clone https://github.com/openresty/redis2-nginx-module.git /tmp/redis2-nginx-module \&& git clone https://github.com/openresty/headers-more-nginx-module.git /tmp/headers-more-nginx-module \&& git clone https://github.com/FRiCKLE/ngx_cache_purge.git /tmp/ngx_cache_purge \&& git clone https://github.com/nginx/nginx-acme.git /tmp/nginx-acme# 配置和编译 Nginx
RUN cd nginx-1.29.1 \&& ./configure --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-http_v3_module \--with-mail \--with-mail_ssl_module \--with-stream \--with-stream_realip_module \--with-stream_ssl_module \--with-stream_ssl_preread_module \--add-dynamic-module=/tmp/echo-nginx-module \--add-dynamic-module=/tmp/redis2-nginx-module \--add-dynamic-module=/tmp/nginx-module-vts \--add-dynamic-module=/tmp/rds-json-nginx-module \--add-dynamic-module=/tmp/memc-nginx-module \--add-dynamic-module=/tmp/ngx_http_substitutions_filter_module \--add-dynamic-module=/tmp/headers-more-nginx-module \--add-dynamic-module=/tmp/ngx_cache_purge \--add-dynamic-module=/tmp/nginx-acme \&& make -j$(nproc) modules \&& mkdir -pv /usr/lib/nginx/modules \&& cp objs/*.so /usr/lib/nginx/modules/ \&& cd .. \&& rm -rf nginx-1.29.1 nginx.tar.gz /tmp/*# 第二阶段:最小化的运行环境
FROM nginx:1.29.1# 复制编译好的模块
COPY --from=build /usr/lib/nginx/modules/*.so /usr/lib/nginx/modules/# 创建 Nginx 的默认目录
RUN mkdir -p /etc/nginx/conf.d /var/log/nginx# 复制自定义配置文件(可选)
#COPY nginx.conf /etc/nginx/nginx.conf# 暴露端口
EXPOSE 80 443# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"]


构建命令

root@wolfan-NUC9V7QNX:~/Docker_Build_image# docker build -t wolf-nginx-mulit:1.29.1 .
[+] Building 1.1s (15/15) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 4.20kB 0.0s
=> [internal] load metadata for docker.io/library/nginx:1.29.1 0.9s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [build 1/9] FROM docker.io/library/nginx:1.29.1@sha256:d5f28ef21aabddd098f3dbc21fe5b7a7d7a184720bc07da0b 0.0s
=> CACHED [build 2/9] RUN apt-get update && apt-get install -y --no-install-recommends build-essential 0.0s
=> CACHED [build 3/9] RUN wget https://github.com/LuaJIT/LuaJIT/archive/refs/tags/v2.1.0-beta3.tar.gz && 0.0s
=> CACHED [build 4/9] RUN ls /usr/local/include/luajit-2.1 0.0s
=> CACHED [build 5/9] RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-to 0.0s
=> CACHED [build 6/9] RUN echo /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bi 0.0s
=> CACHED [build 7/9] RUN curl -fSL https://nginx.org/download/nginx-1.29.1.tar.gz -o nginx.tar.gz && tar 0.0s
=> CACHED [build 8/9] RUN git clone https://github.com/openresty/echo-nginx-module.git /tmp/echo-nginx-modu 0.0s
=> CACHED [build 9/9] RUN cd nginx-1.29.1 && ./configure --with-compat --with-file-aio --with-threads 0.0s
=> CACHED [stage-1 2/3] COPY --from=build /usr/lib/nginx/modules/*.so /usr/lib/nginx/modules/ 0.0s
=> CACHED [stage-1 3/3] RUN mkdir -p /etc/nginx/conf.d /var/log/nginx 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:eebda8668546569b99b80b701783c788de6be06cceaddfa2a44a88a454c1cdd3 0.0s
=> => naming to docker.io/library/wolf-nginx-mulit:1.29.1 0.0s

What's Next?

  1. 1. Sign in to your Docker account → docker login
  2. 2. View a summary of image vulnerabilities and recommendations → docker scout quickview

2.为什么要多段构建

多段构建就是为了保持最小的镜像体积(下面就是多段构建和没有多段构建的区别)

root@wolfan-NUC9V7QNX:~/Docker_Build_image# docker images |grep 1.29
wolf-nginx-mulit                                                 1.29.1                         eebda8668546   7 hours ago     206MB
wolf-nginx-nomulit                                               1.29.1                         f5fe69dfb6f3   7 hours ago     2.42GB

3.启动一个nginx看是否有了加载的模块

# 启动一个容器并查看ID
root@wolfan-NUC9V7QNX:~/Docker_Build_image# docker run -it -d --name wolf-nginx-mulit wolf-nginx-mulit:1.29.1
f49189c25fe5b80f135df3396098c6019216f89c7d5524d012c68d78522cd777
root@wolfan-NUC9V7QNX:~/Docker_Build_image# docker ps |grep wolf-nginx-mulit
f49189c25fe5   wolf-nginx-mulit:1.29.1                                                 "/docker-entrypoint.…"    10 seconds ago   Up 9 seconds             80/tcp, 443/tcp                                                                                wolf-nginx-mulit
# 进入已经启动的容器
root@wolfan-NUC9V7QNX:~/Docker_Build_image# docker exec -it f49189c25fe5 /bin/bash
# 可以看到所有模块
root@f49189c25fe5:/# ls /usr/lib/nginx/modules/
ngx_http_acme_module.so			ngx_http_image_filter_module-debug.so  ngx_http_rds_json_filter_module.so	ngx_http_xslt_filter_module.so
ngx_http_echo_module.so			ngx_http_image_filter_module.so        ngx_http_redis2_module.so		ngx_stream_geoip_module-debug.so
ngx_http_geoip_module-debug.so		ngx_http_js_module-debug.so	       ngx_http_subs_filter_module.so		ngx_stream_geoip_module.so
ngx_http_geoip_module.so		ngx_http_js_module.so		       ngx_http_vhost_traffic_status_module.so	ngx_stream_js_module-debug.so
ngx_http_headers_more_filter_module.so	ngx_http_memc_module.so		       ngx_http_xslt_filter_module-debug.so	ngx_stream_js_module.so

因为折腾一天流水线改造,所以功能上我还没有验证,应该没什么问题,待我边整理流水线边把acme这个功能输出给大家!

image-20250908171958500

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

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

DrissionPage 优化天猫店铺商品爬虫:现代化网页抓取技术详解

概述在网络数据采集领域,传统的爬虫方法通常面临反爬机制、动态内容加载和效率低下等挑战。本文将以天猫店铺商品爬虫为例,详细介绍如何从传统的 Requests 库迁移到更现代化的 DrissionPage 解决方案,实现更高效、稳定的数据采集。----------…

pytest并发测试,资源问题导致用例失败解决办法

遇见的问题: 测试用例使用thrift资源和redis资源,单独运行case没有问题,但是使用并发pytest-xdist(-n 10 和 --distloadscope)运行失败原因: 测试用例间存在共享资源竞争(如 Redis、Thrift 连接…

C 盘又满了?6 个「零风险清理法」+5 款神器,让电脑瞬间多出 100GB 空间

你是否遇到过这样的场景:正在赶工写报告,突然弹出「C 盘存储空间不足」的警告;想安装新软件,却因为 C 盘爆红而反复失败;甚至电脑越来越卡,开机要等 5 分钟,打开文件夹都要转圈…… 作为系统盘…

Android 项目:画图白板APP开发(四)——笔锋(单 Path)

上一章讲解了如何通过多个 Path 叠加形成笔锋效果,还有另外的方式实现笔锋,并且只需要一条Path就可以了。在讲解具体方案之前,我们需要了解一个有意思的工具 PathMeasure ,这是一个非常强大且实用的工具,常用于高级动画…

从C++开始的编程生活(7)——取地址运算符重载、类型转换、static成员和友元

前言 本系列文章承接C语言的学习,需要有C语言的基础才能学会哦~ 第7篇主要讲的是有关于C的取地址运算符重载、类型转换、static成员和友元。 C才起步,都很简单 目录 前言 取地址运算符重载 const成员函数 基本语法 特点 取地址运算符重载 类型转换…

SQL 入门指南:排序与分页查询(ORDER BY 多字段排序、LIMIT 分页实战)

在 SQL 查询中,我们常需要 “按报名时间先后看活动名单”“只看第 2 页的活动报名数据”—— 这些需求靠基础查询无法实现,而ORDER BY(排序) 和LIMIT(分页) 就是解决这类问题的核心工具。今天我们用 “校园…

jodconverter将word转pdf底层libreoffice的问题

近期项目中使用了word转pdf的功能&#xff0c;其中借助了远程服务的jodconverter来处理。 <dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-remote</artifactId><version>4.4.2</version> </dependen…

【为YOLOv11Seg添加MFC界面】详细指南

要将现有的YOLOv11Seg代码集成到MFC界面中,我们需要创建一个MFC应用程序框架,并将现有的检测逻辑封装到其中。以下是详细步骤: 1. 创建MFC应用程序框架 1.1 使用Visual Studio创建MFC项目 打开Visual Studio,选择"创建新项目" 选择"MFC应用程序"模板…

机器学习03——线性模型(多元线性回归、对数线性回归、二分类、线性判别分析)

上一章&#xff1a;机器学习02——模型评估与选择 下一章&#xff1a;机器学习04——决策树 机器学习实战项目&#xff1a;【从 0 到 1 落地】机器学习实操项目目录&#xff1a;覆盖入门到进阶&#xff0c;大学生就业 / 竞赛必备 文章目录一、线性模型的基本形式&#xff08;一…

qt QLineSeries详解

1、概述QLineSeries是Qt Charts模块中的一个重要类&#xff0c;用于绘制折线图。它是QXYSeries的实现类&#xff0c;将信息显示为由直线连接的一系列数据点。该类为QAbstractSeries的子类&#xff0c;因此可以通过该类来访问QAbstractSeries的所有公共方法和属性。2、重要方法c…

你再也找不到更详细的3DGS教程了 —— 一万九千字长文解析3DGS

参考: https://www.bilibili.com/video/BV1MF4m1V7e3/ https://blog.csdn.net/2401_86810419/article/details/148811121 https://www.bilibili.com/video/BV1cz421872F?t=233.9 https://wuli.wiki/online/SphHar.html https://zhuanlan.zhihu.com/p/467466131 特别指出…

Python,遗传算法与神经网络架构搜索:基于DEAP的自动模型设计

引言&#xff1a;当进化论遇见深度学习——自动化的黎明在深度学习的蛮荒时代&#xff0c;我们是“手工匠人”。我们依靠直觉、前辈的经验&#xff08;ResNet 为什么是152层而不是153层&#xff1f;&#xff09;、大量的试错以及那么一点点玄学&#xff0c;在架构的黑暗森林中摸…

Vue框架技术详解——项目驱动概念理解【前端】【Vue】

Vue3框架 是前端渲染框架浏览器向服务器第一次发送请求&#xff0c;就会将所有页面的样式全部返回到浏览器vue中会将所有js文件最后打包成一个js文件&#xff0c;当前访问其中一个页面时&#xff0c;其他页面的样式也已经返回到浏览器中了&#xff0c;下次切换页面时&#xff…

HTML 网页静态托管 API 接口文档(可集成到智能体Agent)

HTML 网页静态托管 API 接口文档&#xff08;可集成到智能体Agent&#xff09; 接口概述 本接口用于将HTML代码转换为可访问的网页&#xff0c;支持通过API密钥进行身份验证。 API 密钥申请地址&#xff1a; https://www.cuobiezi.net/user/api_keys/apply API接口信息 接…

springboot vue sse消息推送,封装系统公共消息推送前后端方法

概述 1、封装springboot全局的消息推送接口&#xff1b; 注&#xff1a;1&#xff09;由于原生HTML5 EventSource 不支持添加header&#xff0c;所以要把连接创建接口加入身份验证白名单&#xff0c;并在接口内添加自己校验token2&#xff09;后台需定时心跳&#xff0c;保证链…

LeetCode 每日一题 2025/9/1-2025/9/7

记录了初步解题思路 以及本地实现代码&#xff1b;并不一定为最优 也希望大家能一起探讨 一起进步 目录9/1 1792. 最大平均通过率9/2 3025. 人员站位的方案数 I9/3 3027. 人员站位的方案数 II9/4 3516. 找到最近的人9/5 2749. 得到整数零需要执行的最少操作数9/6 3495. 使数组元…

小迪安全v2023学习笔记(八十讲)—— 中间件安全WPS分析WeblogicJenkinsJettyCVE

文章目录前记服务攻防——第八十天中间件安全&HW2023-WPS分析&Weblogic&Jetty&Jenkins&CVE应用WPS - HW2023-RCE&复现&上线CS介绍漏洞复现中间件 - Weblogic-CVE&反序列化&RCE介绍利用中间件 - Jenkins-CVE&RCE执行介绍漏洞复现CVE-20…

各webshell管理工具流量分析

哥斯拉哥斯拉是一个基于流量、HTTP全加密的webshell管理工具 特点 1.内置了3种Payload以及6种加密器&#xff0c;6种支持脚本后缀&#xff0c;20个内置插件 2.基于java&#xff0c;可以跨平台使用 3.可以自己生成webshell&#xff0c;根据管理来生成一些payload&#xff0c;然后…

pytest(1):fixture从入门到精通

pytest&#xff08;1&#xff09;&#xff1a;fixture从入门到精通前言1. Fixture 是什么&#xff1f;为什么我们需要它&#xff1f;2. 快速上手&#xff1a;第一个 Fixture 与基本用法3. 作用域 (Scope)&#xff1a;控制 Fixture 的生命周期4. 资源管理&#xff1a;Setup/Tear…

Java17 LTS 新特性用例

基于 Java 17 LTS 的 实用示例 以下是基于 Java 17 LTS 的 30 个实用示例,涵盖语言新特性、API 改进及常见场景。所有代码均兼容 Java 17 语法规范。 文本块(Text Blocks) String json = """{"name": "Java 17","type": &qu…