如何在NginX Docker镜像中使用more_clear_headers

sulc1iza  于 2023-04-05  发布在  Nginx
关注(0)|答案(1)|浏览(302)

我已经启动了nginx并运行了Docker

more_clear_headers 'Server';
more_clear_headers 'X-Powered-By';

之后它就停止工作了。显然这是由一个名为nginx-plus-module-headers-more的模块提供的。我有一个Dockfile

FROM nginx:latest

RUN apt update && apt install -y iputils-ping wget

COPY ./nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
EXPOSE 443

由于这个容器已经在运行,因此连接了一个bash并执行了以下命令:

#> apt update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian-security bullseye-security InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.

#> apt  install -y libnginx-mod-http-headers-more-filter
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies: nginx : Conflicts: nginx-common but 1.18.0-6.1+deb11u3 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
#>

在这一点上,我得到的印象,我已经采取了错误的转折。任何建议,我应该如何安装这个模块?

dfddblmv

dfddblmv1#

只需在apt安装的末尾添加:

FROM nginx:latest

RUN apt update && apt install -y iputils-ping wget libnginx-mod-http-headers-more-filter  # <- HERE

COPY ./nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
EXPOSE 443

相关问题