如何在Nginx Alpine Docker映像中启用本机模块

暴动

我想使用http://nginx.org/en/docs/http/ngx_http_realip_module.html指示启用--with-http_realip_module它。

我正在使用docker使用此Nginx

FROM nginx:alpine

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

现在如何在此docker中启用此模块?我可以在传递参数时docker run还是需要更改dockerfile吗?

先生。

nginx默认情况下没有构建--with-http_realip_module

您可以通过检查nginx:alpine docker images验证模块是否构建

$ docker run --rm nginx:alpine nginx -V
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
nginx version: nginx/1.19.6
built by gcc 9.3.0 (Alpine 9.3.0)
built with OpenSSL 1.1.1g  21 Apr 2020 (running with OpenSSL 1.1.1i  8 Dec 2020)
TLS SNI support enabled
configure arguments: --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 --with-perl_modules_path=/usr/lib/perl5/vendor_perl --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_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-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer' --with-ld-opt=-Wl,--as-needed

如您所见,--with-http_realip_module在那里。

您需要做的就是用来适当配置nginx(在中nginx.conf

例如:

set_real_ip_from  192.168.1.0/24;
set_real_ip_from  192.168.2.1;
set_real_ip_from  2001:0db8::/32;
real_ip_header    X-Forwarded-For;
real_ip_recursive on;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Docker / Alpine:如何在Alpine映像上安装NodeJS 4.8.4

如何在Alpine Linux映像上启用busybox httpd

如何在基于Alpine的Docker映像中使用bash?

如何在Alpine Linux中安装Go

如何在Alpine Linux中安装npm

如何在Alpine容器中安装SSHFS?

如何在php:7.4-fpm-alpine docker容器中启用xdebug?

如何在基于Alpine的Docker容器中配置umask

如何在Docker php-fpm alpine中安装LDAP

如何在Alpine Docker容器中运行Bash脚本?

如何在 docker alpine 中安装 mongodb 客户端?

如何在 alpine base docker image 中设置时区?

如何在Docker Alpine Linux容器中运行Postgres?

Docker:如何在基于Alpine的Docker镜像中使用bash?

如何在Docker的官方php-fpm-alpine映像上安装XDebug?

如何在Alpine.js中编写数组

如何在Alpine中安装特定的软件包版本?

如何在基于Alpine的容器中安装rar?

如何在 alpine js 中获取动态文本值?

如何在Alpine.js中更改共享状态?

如何在Ubuntu中配置Alpine以读取我的Gmail?

如何找到 golang 标签的 Docker alpine 版本?

当apk添加失败时,如何在gliderlabs / alpine Docker镜像中安装Alpine Linux软件包?

如何在Alpine Linux中的Php7中启用短标签?

错误:无法启动 nginx,因为网络无法在 alpine docker 映像上启动

在Alpine上运行Nginx

如何让/ etc / profile在Alpine / Docker中自动运行

docker-compose chrome-alpine使用nginx

如何在 Docker/Alpine 中安装 MariaDB ODBC 驱动程序