首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >此处不允许使用Nginx "upstream“指令

此处不允许使用Nginx "upstream“指令
EN

Stack Overflow用户
提问于 2021-05-17 14:01:41
回答 1查看 423关注 0票数 1

我正在尝试用uwsgi和nginx建立一个Django网站。我创建了配置文件mysite.conf

代码语言:javascript
复制
# the upstream component nginx needs to connect to
upstream django {
    server unix:///home/path/to/mysite/mysite.sock;
}

# configuration of the server
server {
    listen      80;
    server_name mydomain.com www.mydomain.com;
    charset     utf-8;
    # max upload size
    client_max_body_size 350M;

    # Django media and static files
    location /media  {
        alias /home/path/to/mysite/media;
    }
    location /static {
        alias /home/path/to/mysite/static;
    }

    # Send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/path/to/mysite/uwsgi_params;
    }
}

它给出了这个错误:

代码语言:javascript
复制
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-enabled/mysite.conf:2

我不知道为什么会这样。我遵循了这个教程:https://tonyteaches.tech/django-nginx-uwsgi-tutorial/

EN

回答 1

Stack Overflow用户

发布于 2021-05-17 15:00:22

问题是我在http标签之前包含了配置文件。它应该是:

代码语言:javascript
复制
http {
    include /etc/nginx/sites-enabled/*;
    ...
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67564646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档