我正在尝试用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/
发布于 2021-05-17 15:00:22
问题是我在http标签之前包含了配置文件。它应该是:
http {
include /etc/nginx/sites-enabled/*;
...
}https://stackoverflow.com/questions/67564646
复制相似问题