I'm trying to set up a Django website with uwsgi and nginx. I created configuration file 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;
}
}
And it gives this error:
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-enabled/mysite.conf:2
I don't why it happens. I followed this tutorial: https://tonyteaches.tech/django-nginx-uwsgi-tutorial/
The problem was that i included configuration files before http tag. It should be:
http {
include /etc/nginx/sites-enabled/*;
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With