【问题标题】:nginx directive is not allowed here in unicorn's example nginx.conf在 unicorn 的示例 nginx.conf 中不允许使用 nginx 指令
【发布时间】:2013-10-09 20:10:02
【问题描述】:

我正在使用 nginx 1.4.1。复制unicorn's example of nginx.conf 后,我发现设置必须移动到不同的指令。我仍然无法将以下设置放入 nginx.conf 文件中:worker_processesuserpidevents 块。当我按原样放置它们时,日志显示directive is not allowed here。我应该解决什么问题?

worker_processes 1;
user deployer sudo; # for systems with a "nogroup"
pid /run/nginx.pid;

events {
  worker_connections 1024; # increase if you have lots of clients
  accept_mutex off; # "on" if nginx worker_processes > 1
}

upstream abc {
  ...
}

server {
  ...
}

更新 1

我知道这个post,但奇怪的是我所做的一切都不起作用。我在 nginx 中找不到任何文档。

【问题讨论】:

  • 与上面的代码相比,您的http { 块在哪里?

标签: nginx unicorn


【解决方案1】:

原例子不能直接使用,因为主配置在/etc/nginx/nginx.conf/etc/nginx/nginx.conf 具有 http 指令,其中包括 sites-enabled/* 指令。对/etc/nginx/nginx.conf 进行的唯一更改是:

work_processes 4;
worker_connections 1024;

此外,请从中删除 text/html,因为它已默认压缩。

您的应用中nginx.conf 的最终结果应该没有http 指令,只有upstreamserver

【讨论】:

    猜你喜欢
    • 2020-02-09
    • 1970-01-01
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多