nginx: [emerg] "upstream" directive is not allowed

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx: [emerg] "upstream" directive is not allowed相关的知识,希望对你有一定的参考价值。

配置完nginx,在启动的时候遇到如下问题:
nginx: [emerg] "upstream" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:7

配置nginx.conf,如下:
upstream con {
    server 127.0.0.1:8080;
}


解决办法:

upstream backend 位置放错了, upstream位置应该放在http模块里面 但必须是在server模块的外面


http
{
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    ..................................................

    upstream con {
    server 127.0.0.1:8080;
}

}
对此段代码放入httpd模块中,重启服务可完成问题的解决。

以上是关于nginx: [emerg] "upstream" directive is not allowed的主要内容,如果未能解决你的问题,请参考以下文章

nginx: [emerg] "server" 指令在这里不允许

nginx:[emerg]unknown directive "ssl"

nginx: [emerg] "upstream" directive is not allowed

nginx: [emerg] getpwnam("www") failed

django- nginx: [emerg] open() "/etc/nginx/proxy_params" 在 /etc/nginx/sites-enabled/myproje

nginx 启动报错 nginx: [emerg] getgrnam("root") failed