nginx unknown directive “upstream”

坚强是说给别人听的谎言 提交于 2019-12-02 20:36:37

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.

I am using nginx version: nginx/1.4.1 on EC2 Ubuntu. I was getting this error:

nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/nginx.conf

To get my instance running I had to wrap the upstream and server sections in an http { } section. It then complained about missing event section. So I added that as follows:

events { worker_connections 1024; }

It worked fine after those fixes, this is my first effort so I was guessing my way through.

Turns my nginx config was ok. The problem was with my gunicorn server was not running properly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!