[GH-ISSUE #972] 如何增加nginx模块 #6293

Closed
opened 2026-03-01 17:10:54 +03:00 by kerem · 10 comments
Owner

Originally created by @chung1912 on GitHub (Apr 18, 2025).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/972

对于需要编译增加nginx插件的情形,比如增加ngx_http_proxy_connect_module这样的nginx模块,要如何结合nginx-ui来使用?
nginx-ui和nginx内核是一体的,怎么让自己编译的又自定义插件的nginx进去呢?

Originally created by @chung1912 on GitHub (Apr 18, 2025). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/972 对于需要编译增加nginx插件的情形,比如增加`ngx_http_proxy_connect_module`这样的nginx模块,要如何结合nginx-ui来使用? nginx-ui和nginx内核是一体的,怎么让自己编译的又自定义插件的nginx进去呢?
kerem closed this issue 2026-03-01 17:10:54 +03:00
Author
Owner

@0xJacky commented on GitHub (Apr 18, 2025):

您可以创建 Dockerfile 尝构建自己的 nginx,并使用脚本安装 nginx-ui。

<!-- gh-comment-id:2814846483 --> @0xJacky commented on GitHub (Apr 18, 2025): 您可以创建 Dockerfile 尝构建自己的 nginx,并使用脚本安装 nginx-ui。
Author
Owner

@chung1912 commented on GitHub (Apr 18, 2025):

您可以创建 Dockerfile 尝构建自己的 nginx,并使用脚本安装 nginx-ui。

我需要用docker容器运行nginx-ui,是不是把本项目中的dockerfile文件里面的uozi/nginx-ui-base:latest,直接替换为我自己构建的nginx,然后制作 nginx-ui镜像?

<!-- gh-comment-id:2814853565 --> @chung1912 commented on GitHub (Apr 18, 2025): > 您可以创建 Dockerfile 尝构建自己的 nginx,并使用脚本安装 nginx-ui。 我需要用docker容器运行nginx-ui,是不是把本项目中的dockerfile文件里面的uozi/nginx-ui-base:latest,直接替换为我自己构建的nginx,然后制作 nginx-ui镜像?
Author
Owner

@freshgeek commented on GitHub (Apr 19, 2025):

感觉是这里 ,https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,还挺复杂的,可以一起交流下 我也要自定义自己的模块镜像

<!-- gh-comment-id:2816717552 --> @freshgeek commented on GitHub (Apr 19, 2025): 感觉是这里 ,https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,还挺复杂的,可以一起交流下 我也要自定义自己的模块镜像
Author
Owner

@freshgeek commented on GitHub (Apr 21, 2025):

研究了两天,发现坑坑不一样,同步一下发现还挺多人想这么做

先说下流程,需要了解的事情:

  1. 首先得知道如何打包nginx 模块封装成nginx 镜像,并且需要使用deb的基础镜像,因为nginx-ui用到了
  2. 打包好后封装成nginx-ui-base 镜像
  3. 构建nginx-ui 前端、后端、打包+镜像逻辑

详细步骤

  1. 打包nginx 基础镜像并且需要deb的基础镜像,教程看这边 https://github.com/nginx/docker-nginx/blob/master/modules/README.md 编译自定义模块教程 ,自有和三方都描述了具体步骤,至于docker-compose的用法就不再描述了

  2. 然后就是使用jacky的 https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,然后修改为上一步打包出来的镜像, 需要在根目录执行 : docker build -f nginx-ui-base/Dockerfile -t nginx-ui-base .

  3. 这时打包好了nginx-ui-base, clone nginx-ui 项目 将Dockerfile文件中的from改成使用第2步带nginx模块的基础镜像

  4. 打包:先编译前端,使用node21+ 、pnpm install && pnpm build ;

  5. 然后编译后端 需要go 1.23+ go generate
    go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go

  6. 然后还有一步,因为前面打包后端是输出到根目录的-o nginx-ui dockerfile 是兼容 github流水线 https://github.com/0xJacky/nginx-ui/blob/dev/.github/workflows/build.yml ,所以这里可以直接将Dockerfile中
    COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui
    改为
    COPY nginx-ui /usr/local/bin/nginx-ui

  7. 然后开始打包nginx-ui镜像即可输出最终的 带自定义模块的nginx-ui ,再提一嘴,打包好的模块默认是没有加载的,需要再nginx.conf 首行手动load模块 类似这样
    load_module "modules/ngx_http_image_filter_module.so";

模块都在/etc/nginx/modules 下面,直接用不带debug的就行

<!-- gh-comment-id:2817432041 --> @freshgeek commented on GitHub (Apr 21, 2025): 研究了两天,发现坑坑不一样,同步一下发现还挺多人想这么做 先说下流程,需要了解的事情: 1. 首先得知道如何打包nginx 模块封装成nginx 镜像,并且需要使用deb的基础镜像,因为nginx-ui用到了 2. 打包好后封装成nginx-ui-base 镜像 3. 构建nginx-ui 前端、后端、打包+镜像逻辑 # 详细步骤 1. 打包nginx 基础镜像并且需要deb的基础镜像,教程看这边 https://github.com/nginx/docker-nginx/blob/master/modules/README.md 编译自定义模块教程 ,自有和三方都描述了具体步骤,至于docker-compose的用法就不再描述了 2. 然后就是使用jacky的 https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,然后修改为上一步打包出来的镜像, 需要在根目录执行 : docker build -f nginx-ui-base/Dockerfile -t nginx-ui-base . 3. 这时打包好了nginx-ui-base, clone nginx-ui 项目 将Dockerfile文件中的from改成使用第2步带nginx模块的基础镜像 4. [打包](https://github.com/0xJacky/nginx-ui?tab=readme-ov-file#manual-build):先编译前端,使用node21+ 、pnpm install && pnpm build ; 5. 然后编译后端 需要go 1.23+ go generate go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go 6. 然后还有一步,因为前面打包后端是输出到根目录的`-o nginx-ui` dockerfile 是兼容 github流水线 https://github.com/0xJacky/nginx-ui/blob/dev/.github/workflows/build.yml ,所以这里可以直接将Dockerfile中 COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui 改为 COPY nginx-ui /usr/local/bin/nginx-ui 7. 然后开始打包nginx-ui镜像即可输出最终的 带自定义模块的nginx-ui ,再提一嘴,打包好的模块默认是没有加载的,需要再nginx.conf 首行手动load模块 类似这样 load_module "modules/ngx_http_image_filter_module.so"; 模块都在/etc/nginx/modules 下面,直接用不带debug的就行
Author
Owner

@chung1912 commented on GitHub (Apr 21, 2025):

研究了两天,发现坑坑不一样,同步一下发现还挺多人想这么做

先说下流程,需要了解的事情:

  1. 首先得知道如何打包nginx 模块封装成nginx 镜像,并且需要使用deb的基础镜像,因为nginx-ui用到了
  2. 打包好后封装成nginx-ui-base 镜像
  3. 构建nginx-ui 前端、后端、打包+镜像逻辑

详细步骤

  1. 打包nginx 基础镜像并且需要deb的基础镜像,教程看这边 https://github.com/nginx/docker-nginx/blob/master/modules/README.md 编译自定义模块教程 ,自有和三方都描述了具体步骤,至于docker-compose的用法就不再描述了
  2. 然后就是使用jacky的 https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,然后修改为上一步打包出来的镜像, 需要在根目录执行 : docker build -f nginx-ui-base/Dockerfile -t nginx-ui-base .
  3. 这时打包好了nginx-ui-base, clone nginx-ui 项目 将Dockerfile文件中的from改成使用第2步带nginx模块的基础镜像
  4. 打包:先编译前端,使用node21+ 、pnpm install && pnpm build ;
  5. 然后编译后端 需要go 1.23+ go generate
    go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go
  6. 然后还有一步,因为前面打包后端是输出到根目录的-o nginx-ui dockerfile 是兼容 github流水线 https://github.com/0xJacky/nginx-ui/blob/dev/.github/workflows/build.yml ,所以这里可以直接将Dockerfile中
    COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui
    改为
    COPY nginx-ui /usr/local/bin/nginx-ui
  7. 然后开始打包nginx-ui镜像即可输出最终的 带自定义模块的nginx-ui ,再提一嘴,打包好的模块默认是没有加载的,需要再nginx.conf 首行手动load模块 类似这样
    load_module "modules/ngx_http_image_filter_module.so";

模块都在/etc/nginx/modules 下面,直接用不带debug的就行

这个好复杂,如果要更新的话还挺费劲的。后续会出独立ui版,和nginx分开部署,这样的话就方便多了,ui部署的时候环境变量里面直接指定外部nginx,这样就方便多了

<!-- gh-comment-id:2817438989 --> @chung1912 commented on GitHub (Apr 21, 2025): > 研究了两天,发现坑坑不一样,同步一下发现还挺多人想这么做 > > 先说下流程,需要了解的事情: > > 1. 首先得知道如何打包nginx 模块封装成nginx 镜像,并且需要使用deb的基础镜像,因为nginx-ui用到了 > 2. 打包好后封装成nginx-ui-base 镜像 > 3. 构建nginx-ui 前端、后端、打包+镜像逻辑 > > # 详细步骤 > 1. 打包nginx 基础镜像并且需要deb的基础镜像,教程看这边 https://github.com/nginx/docker-nginx/blob/master/modules/README.md 编译自定义模块教程 ,自有和三方都描述了具体步骤,至于docker-compose的用法就不再描述了 > 2. 然后就是使用jacky的 https://github.com/0xJacky/uozi-docker/blob/main/nginx-ui-base/Dockerfile ,然后修改为上一步打包出来的镜像, 需要在根目录执行 : docker build -f nginx-ui-base/Dockerfile -t nginx-ui-base . > 3. 这时打包好了nginx-ui-base, clone nginx-ui 项目 将Dockerfile文件中的from改成使用第2步带nginx模块的基础镜像 > 4. [打包](https://github.com/0xJacky/nginx-ui?tab=readme-ov-file#manual-build):先编译前端,使用node21+ 、pnpm install && pnpm build ; > 5. 然后编译后端 需要go 1.23+ go generate > go build -tags=jsoniter -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go > 6. 然后还有一步,因为前面打包后端是输出到根目录的`-o nginx-ui` dockerfile 是兼容 github流水线 https://github.com/0xJacky/nginx-ui/blob/dev/.github/workflows/build.yml ,所以这里可以直接将Dockerfile中 > COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui > 改为 > COPY nginx-ui /usr/local/bin/nginx-ui > 7. 然后开始打包nginx-ui镜像即可输出最终的 带自定义模块的nginx-ui ,再提一嘴,打包好的模块默认是没有加载的,需要再nginx.conf 首行手动load模块 类似这样 > load_module "modules/ngx_http_image_filter_module.so"; > > 模块都在/etc/nginx/modules 下面,直接用不带debug的就行 这个好复杂,如果要更新的话还挺费劲的。后续会出独立ui版,和nginx分开部署,这样的话就方便多了,ui部署的时候环境变量里面直接指定外部nginx,这样就方便多了
Author
Owner

@dmiales commented on GitHub (Apr 29, 2025):

@chung1912
Do I understand correctly that it will be possible to launch a docker container with NGINX and separately launch a docker container with NGINX-UI, where I will specify the path to the first container with NGINX?

<!-- gh-comment-id:2838049027 --> @dmiales commented on GitHub (Apr 29, 2025): @chung1912 Do I understand correctly that it will be possible to launch a docker container with NGINX and separately launch a docker container with NGINX-UI, where I will specify the path to the first container with NGINX?
Author
Owner

@0xJacky commented on GitHub (Apr 29, 2025):

Hi @dmiales, this feature will be released in the next rc version.

<!-- gh-comment-id:2838185103 --> @0xJacky commented on GitHub (Apr 29, 2025): Hi @dmiales, this feature will be released in the next rc version.
Author
Owner

@luisyoroslav commented on GitHub (May 7, 2025):

Hi @dmiales, this feature will be released in the next rc version.

Hi @0xJacky, When do you think this change will be available?

<!-- gh-comment-id:2860572193 --> @luisyoroslav commented on GitHub (May 7, 2025): > Hi [@dmiales](https://github.com/dmiales), this feature will be released in the next rc version. Hi @0xJacky, When do you think this change will be available?
Author
Owner

@0xJacky commented on GitHub (May 7, 2025):

Hi @dmiales, this feature will be released in the next rc version.

Hi @0xJacky, When do you think this change will be available?

This feature is already available, refer to https://nginxui.com/guide/config-nginx.html#container-control for more details.

<!-- gh-comment-id:2860685375 --> @0xJacky commented on GitHub (May 7, 2025): > > Hi [@dmiales](https://github.com/dmiales), this feature will be released in the next rc version. > > Hi @0xJacky, When do you think this change will be available? This feature is already available, refer to https://nginxui.com/guide/config-nginx.html#container-control for more details.
Author
Owner

@luisyoroslav commented on GitHub (May 7, 2025):

Hi @dmiales, this feature will be released in the next rc version.

Hi @0xJacky, When do you think this change will be available?

This feature is already available, refer to https://nginxui.com/guide/config-nginx.html#container-control for more details.

Nice, thanks!

<!-- gh-comment-id:2860854132 --> @luisyoroslav commented on GitHub (May 7, 2025): > > > Hi [@dmiales](https://github.com/dmiales), this feature will be released in the next rc version. > > > > > > Hi [@0xJacky](https://github.com/0xJacky), When do you think this change will be available? > > This feature is already available, refer to https://nginxui.com/guide/config-nginx.html#container-control for more details. Nice, thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#6293
No description provided.