【发布时间】:2021-08-06 10:01:42
【问题描述】:
我正在尝试使用 uwsgi 和 nginx 建立一个 Django 网站。我创建了配置文件mysite.conf:
# 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;
}
}
它给出了这个错误:
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-enabled/mysite.conf:2
我不知道为什么会这样。我遵循了这个教程:https://tonyteaches.tech/django-nginx-uwsgi-tutorial/
【问题讨论】: