Search code examples
djangonginxuwsgi

Nginx not serving django 3 through wsgi


I am trying to serve a Django 3 build from nginx through wsgi and I cannot seem to get the last stage. I can browse to the Django site by a runserver and launching the uwsgi.ini, but, when I try to browse to the site through nginx I get a 502 error (bad gateway)(firefox). If I try from a remote site it renders the nginx home page.

I have a build of Apache on the same server. I had to spoof an IP and use a unique port to get them running side by side.

the nginx/error.log does not register any problem.

Below is the uwsgi.ini.

[uwsgi]
# variables
projectname = website
base = /opt/website/
# configuration
master = true
http = :8000
uid = nginx
virtualenv = /opt/website/djangoprojectenv
pythonpath = %(base)
chdir = %(base)
env = DJANGO_SETTINGS_MODULE=%(projectname).settings.pro
#module = %(projectname).wsgi:application
module = website.wsgi:application
socket = /tmp/%(projectname).new.sock
chown-socket = %(uid):nginx
chmod-socket = 666

And below is the conf file from nginx/conf.d

server {
    listen 192.168.1.220:81;
    server_name willdoit.com;

    access_log  off;
    error_log  /var/log/nginx_error.log;

    location / {
        uwsgi_pass unix:/tmp/website.sock;
        include /etc/nginx/uwsgi_params;
        uwsgi_read_timeout 300s;
        client_max_body_size 32m;
    }
}

The /tmp/website.sock file is owned by nginx:nginx.

If there are additional details I need to post, please advise. Any help you can provide would be welcome.


Solution

  • The socket was defined incorrectly. Closing.