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

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

问题描述

我是NGINX的新手,我正在尝试设置最少的工作内容.因此,我尝试使用nginx和超级用户运行aiohttp微型应用程序(通过示例).但是我无法正确配置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 include sites-enabled/*;

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天全站免登陆