本镜像为预配置了额外模块的Nginx镜像,旨在提供增强的Web服务器功能。除基础Nginx功能外,还集成了特定扩展模块,并支持通过环境变量动态渲染配置模板,适用于需要自定义认证机制或动态配置管理的场景。
/etc/nginx/conf.templates.d/ 目录下的模板文件envsubst 工具进行变量替换NGINX_TEMPLATE_VARS 环境变量中指定的变量(变量间用逗号分隔,无空格)bashdocker run -d --name nginx-extra-modules -p 80:80 your-image-name
1. 准备模板文件
将需动态配置的Nginx配置文件(如 nginx.conf.template)放置在宿主机目录(如 ./conf.templates),模板中使用 ${VARIABLE_NAME} 标记需替换的变量。
2. 设置环境变量
通过 -e 参数指定 NGINX_TEMPLATE_VARS 及其他需替换的变量:
bashdocker run -d \ --name nginx-extra-modules \ -p 80:80 \ -v ./conf.templates:/etc/nginx/conf.templates.d \ -e NGINX_TEMPLATE_VARS="BACKEND_HOST,PORT" \ -e BACKEND_HOST="192.168.1.100" \ -e PORT="8080" \ your-image-name
3. 模板渲染逻辑
容器启动时,会处理 /etc/nginx/conf.templates.d/ 下的所有模板文件,将 ${BACKEND_HOST} 和 ${PORT} 替换为环境变量值,并生成最终配置文件。
如需使用ldap模块,需在Nginx配置中添加相应配置,例如:
nginxserver { listen 80; server_name example.com; auth_ldap "LDAP Authentication"; auth_ldap_url "ldap://ldap.example.com:389/dc=example,dc=com?uid?sub?(objectClass=*)"; auth_ldap_binddn "cn=admin,dc=example,dc=com"; auth_ldap_binddn_passwd "password"; auth_ldap_group_attribute member; auth_ldap_group_attribute_is_dn on; auth_ldap_require group "cn=nginx-users,ou=groups,dc=example,dc=com"; location / { root /usr/share/nginx/html; index index.html; } }
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务