0

Solved

see bottom for fixes etc.

I'm trying to connetc my django app with nginx via uwsgi, but it seems that the passing of data to uwsgi does not happen. I've tested that the uwsgi server is running properly and do not get any log output on either end.

uwsgi.ini

[uwsgi] module = MyDjangoApp.wsgi:application master = True ;http-socket = :8001 #to run uwsgi on its one to ensure that it works socket = :8001 vacuum = True max-requests = 5000 plugin = python3 enable-threads = True 

/etc/nginx/sites-available file tree

  • default
  • serverDjango_nginx.conf

serverDjango_nginx.conf:

# the upstream component nginx needs to connect to upstream django { #server unix:///path/to/your/mysite/mysite.sock; # for a file socket server 127.0.0.1:8001; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 8000; # the domain name it will serve for server_name 127.0.0.1; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Django media # location /media { # location /media { # alias /path/to/your/mysite/media; # your Django project's media files $ # } # location /static { # alias /path/to/your/mysite/static; # your Django project's static files$ # } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /home/pi/Server/uwsgi_params; # the uwsgi_params file you in$ } 

UPDATE:

first the site wasn't enabled... second I've put a link to it in the /etc/nginx/sites-enabled/ as the documentation said now i get this wierd error:

2020/03/29 12:14:18 [emerg] 4344#4344: open() "/etc/nginx/sites-enabled/serverDjango_nginx.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:63

I looked into the corresponding config file to find

 include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; 

and now I am wondering why id does not find the file I've linked to

sudo ln -s ~/etc/nginx/sites-available/serverDjango_nginx.conf /etc/nginx/sites-enabled/

Update No2

so the linkagepath was wrong because of:

sudo ln -s ~/etc/nginx/sites-available/serverDjango_nginx.conf

the tilde there, which forced a relative path, therefore invalidating the link

1 Answer 1

1

This site is a great tool for generating your Nginx config files. In your server block you should be putting the listen to either 80 or 443 (if you want it to be accessible via standard http/s ports). You also should put your server_name to be your domain such as www.google.com google.com (yes include both) or whatever domain(s) you want to serve your Django site on.

I don't use the uwsgi like you do under location either. I just use proxy_pass like proxy_pass http://localhost:8001 and then pass an include for my proxy config.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.