nginx + uwsgi upstream prematurely closed connection while reading response header from upstream

22 views Asked by At

I'm using uwsgi and nginx to deploy a Django project which using VUE3 and Django. And nginx is in a docker container.I have tried several conf combinations, only the follow one works.

    location /cseq/ {
        root /usr/share/nginx/html;
        #try_files $uri $uri/ /cseq/index.html;
        index index.html index.htm;
    }
    location /cseq/api/ {
        proxy_pass http://xxx:8001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
        uwsgi_buffer_size 16k;
        uwsgi_busy_buffers_size 24k;

    }

[uwsgi]
http=:8001
chdir=/root/project/cseq/cseq-backend
module=cseq.wsgi:application
master=true
vacuum=true
max-requests=5000
workers= 4
threads = 2
buffer-size = 65536
daemonize=/root/project/cseq/cseq-backend/uwsgi.log           

My question is: in uwsgi conf, using http works, but change http to socket, nginx has a error:upstream prematurely closed connection while reading response header from upstream.

when I change both conf to the follow

    location /cseq/ {
        root /usr/share/nginx/html;
        #try_files $uri $uri/ /cseq/index.html;
        index index.html index.htm;
    }
    location /cseq/api/ {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8001;
    }
[uwsgi]
socket=:8001
chdir=/root/project/cseq/cseq-backend
module=cseq.wsgi:application
master=true
vacuum=true
max-requests=5000
workers= 4
threads = 2
buffer-size = 65536
daemonize=/root/project/cseq/cseq-backend/uwsgi.log        

the error becomes failed (111: Connection refused) while connecting to upstream, in both errors, uwsgi didn't has any connection. Any ideas or solutions?

I want to use nginx and uwsgi to deploy a Django project

0

There are 0 answers