NGinx“此处不允许指令”错误是什么?我第一次尝试在 Docker 容器中使用 NGinx,并且使用来自其他网站的示例配置,这些配置似乎是正确的配置,但无论如何配置 nginx.conf 文件,我都会收到此错误,我不知道为什么。
2018/03/10 20:52:20 [emerg] 1#1: "user" directive is not allowed
here in /etc/nginx/conf.d/nginx.conf:6
nginx: [emerg] "user" directive is not allowed here
in /etc/nginx/conf.d/nginx.conf:6
Run Code Online (Sandbox Code Playgroud)
链接到我的 Github 项目分支(不是主分支),演示了该问题。
我用谷歌搜索了这个错误,看到很多答案表明这是一个简单的修复,我已经尝试了所有这些。
例如,如果我像这样配置 nginx.conf 文件,则会收到错误:
# nginx.conf
user nobody;
Run Code Online (Sandbox Code Playgroud)
对于我的情况(Docker + 模板)的任何人来说,以下内容可能会有所帮助。
我收到此错误:
nginx: [emerg] "user" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
Run Code Online (Sandbox Code Playgroud)
问题是该模板(至少在这个官方 NGINX Docker 镜像中)并不意味着是完整的配置。它包含在/etc/nginx/nginx.conf图像中文件的 http 块中:
user nginx;
worker_processes auto;
(...)
http {
(...)
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Run Code Online (Sandbox Code Playgroud)
就我而言,解决方案是删除除我自己的http配置之外的所有内容。
感谢 @melpomene 的回复,解决了 3 个问题:
nginx.conf根据 Nginx “复杂配置”文档将其复制到正确的位置。/etc/nginx/logs
文件夹复制(通过 docker run volume mount)到位,因为 Nginx 似乎无法自行创建该文件夹?mime.types文件。我更新的存储库在这里: https ://github.com/djangofan/docker-tomcat7-cluster
| 归档时间: |
|
| 查看次数: |
21577 次 |
| 最近记录: |