Welcome! Log In Create A New Profile

Advanced

Deploying django, channels and websockets with nginx and daphne

Larry Martell
February 26, 2020 05:56PM
I've posted this to the django mailing list and to stack overflow,
with no replies so trying here.

I am trying to deploy a django app that uses channels and websockets,
with nginx and daphne.

When I was using uwsgi, here was my nginx file:

upstream django {
server unix:/run/uwsgi/devAppReporting.sock;
}

server {
listen 8090;
server_name foo.bar.com;
charset utf-8;

location /static {
alias /var/dev-app-reporting/static;
}

location / {
uwsgi_pass django;
include /var/dev-app-reporting/uwsgi_params;
uwsgi_read_timeout 3600;
client_max_body_size 50m;
}
}

Now I changed it to this:

upstream django {
server unix:/run/daphne/devAppReporting.sock;
}

server {
listen 8090;
server_name foo.bar.com;
charset utf-8;

location /static {
alias /var/dev-app-reporting/static;
}

location / {
proxy_pass http://0.0.0.0:8090;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}

Started daphne like this:

daphne -u /run/daphne/devAppReporting.sock app.dse.asgi:application

I get a 502 bad gateway error and this in the log:

2020/02/24 22:17:26 [alert] 29169#29169: 768 worker_connections are not enough
2020/02/24 22:17:26 [error] 29169#29169: *131545 recv() failed (104:
Connection reset by peer) while reading response header from upstream,
client: 127.0.0.1, server:
dse-portfolio-dev-assessments.md.virtualclarity.com, request: "GET /
HTTP/1.1", upstream: "http://0.0.0.0:8090/", host: "xx.xx.xx.xx"

Any ideas on what I should have in my config file for this to work?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Deploying django, channels and websockets with nginx and daphne

Larry Martell February 26, 2020 05:56PM

Re: Deploying django, channels and websockets with nginx and daphne

Francis Daly February 26, 2020 06:40PM

Re: Deploying django, channels and websockets with nginx and daphne

Larry Martell February 27, 2020 09:08AM

Re: Deploying django, channels and websockets with nginx and daphne

Daniel Wilcox February 26, 2020 07:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 103
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready