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/
2
Answers
The problem was that i included configuration files before http tag. It should be:
This can also happen if your file is being deployed over the directory
/etc/nginx/conf.d/
but the default config is including files fromhttp.d
instead:so try also to deploy it over
/etc/nginx/http.d/