gpt4 book ai didi

nginx: [emerg] "http"指令在/etc/nginx/sites-enabled/default:1 中是不允许的

转载 作者:行者123 更新时间:2023-12-03 10:49:30 24 4
gpt4 key购买 nike

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

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

这是完整的 default.conf 文件:
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 是父指令。我做错了什么?

最佳答案

我假设你有 http在你的/etc/nginx/nginx.conf 文件中,然后告诉 nginx 到 include sites-enabled/*;
那么你有

 http
http
server

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

关于nginx: [emerg] "http"指令在/etc/nginx/sites-enabled/default:1 中是不允许的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43643829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com