nginx unknown directive “upstream”

后端 未结 3 553
一个人的身影
一个人的身影 2021-02-02 10:55

I\'m using nginx as a proxy server to forward requests onto my gunicorn server. When I run sudo nginx -t -c /etc/nginx/sites-enabled/mysite I get the following erro

3条回答
  •  星月不相逢
    2021-02-02 11:36

    When you tell nginx to load that file directly, it starts at the global context. The upstream directive is only valid in the http context. When that file is included normally by nginx.conf, it is included already inside the http context:

    events { }
    http {
      include /etc/nginx/sites-enabled/*;
    }
    

    You either need to use -c /etc/nginx/nginx.conf or make a small wrapper like the above block and nginx -c it.

提交回复
热议问题