nginx - 如何解决/etc/nginx/sites-enabled/default :1 这里不允许使用 "http"指令

标签 nginx aiohttp

我关注这个 step但不知何故这会引发错误..

默认配置是

http {
  upstream alert {
    # fail_timeout=0 means we always retry an upstream even if it failed
    # to return a good HTTP response

    # Unix domain servers
    server unix:/tmp/alert_1.sock fail_timeout=0;
    server unix:/tmp/alert_2.sock fail_timeout=0;
    server unix:/tmp/alert_3.sock fail_timeout=0;
    server unix:/tmp/alert_4.sock fail_timeout=0;

    # Unix domain sockets are used in this example due to their high performance,
    # but TCP/IP sockets could be used instead:
    # server 127.0.0.1:8081 fail_timeout=0;
    # server 127.0.0.1:8082 fail_timeout=0;
    # server 127.0.0.1:8083 fail_timeout=0;
    # server 127.0.0.1:8084 fail_timeout=0;
  }
  server {
    listen 80;
    client_max_body_size 4G;

    server_name myiphere;

    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://alert;
    }

    location /static {
      # path for static files
      root /mylocation/static;
    }

  }
}

nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1 nginx: configuration file /etc/nginx/nginx.conf test failed

最佳答案

检查您的 /etc/nginx/nginx.conf .如果您正在开通 http指令,然后再次将其打开到您的 sites-enabled/文件夹 conf 文件,你最终会得到嵌套的 http指示。

关于nginx - 如何解决/etc/nginx/sites-enabled/default :1 这里不允许使用 "http"指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53155138/

相关文章:

ssl - 使用卸载到 ELB 的 SSL 解密在 AWS EC2 nginx 上的重定向中添加的无效端口

ruby-on-rails - 跨 docker 容器共享预编译 Assets

python - aiohttp:限制并行请求的速率

python - 使用同一个ClientSession获取多个不同的url

python - 如何使用aiohttp获取客户端的IP地址

nginx - 在 CentOS 7 上使用 php7 和 nginx 安装 Typo3

Nginx 服务器中的 SSL 握手失败

nginx - 解析 HTTP 404 响应正文时出错 : invalid character '<' looking for beginning of value docker

Python 3.5 async for block ioloop

python - 将 aiohttp 与多处理结合起来