nginx: [emerg] "http";/etc/nginx/sites-enabled/default:1 中不允许使用指令 [英] nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1

查看:24
本文介绍了nginx: [emerg] "http";/etc/nginx/sites-enabled/default:1 中不允许使用指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 NGINX 的新手,我正在尝试设置最少的工作内容.所以我尝试使用 nginx 和主管运行 aiohttp 迷你应用程序(通过 this 示例).但是我无法正确配置 Nginx 并收到以下错误:

I'm new to NGINX and I'm trying to setup minimal working thing. So I trying to run aiohttp mini-app with nginx and supervisor (by this example). But I can't configure Nginx right and getting the following error:

nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1

这是完整的 default.conf 文件:

Here is full default.conf file:

http {
  upstream aiohttp {
    # Unix domain servers
    server unix:/tmp/example_1.sock fail_timeout=0;
    server unix:/tmp/example_2.sock fail_timeout=0;
    server unix:/tmp/example_3.sock fail_timeout=0;
    server unix:/tmp/example_4.sock fail_timeout=0;
  }

  server {
    listen 80;
    client_max_body_size 4G;

    server example.com;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://aiohttp;
    }
  }

}

看起来是正确的.server 指令应该在 http 中.而 http 是父指令.我做错了什么?

It looks correct. server directive is in http as it should be. And http is parent directive. What I'm doing wrong?

推荐答案

我假设你的/etc/nginx/nginx.conf 文件中有 http 然后告诉 nginx 到 包括启用站点的/*;

I am assuming that you have http in your /etc/nginx/nginx.conf file which then tells nginx to include sites-enabled/*;

那么你有

 http
    http
       server

因为 http 指令应该只发生一次,只需从启用站点的配置文件中删除 http 指令

As the http directive should only happen once just remove the http directive from your sites-enabled config file(s)

这篇关于nginx: [emerg] "http";/etc/nginx/sites-enabled/default:1 中不允许使用指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆