Django:失败:WebSocket握手期间出错

Django:失败:WebSocket握手期间出错,django,nginx,websocket,uwsgi,supervisord,Django,Nginx,Websocket,Uwsgi,Supervisord,我在犯错误 到“ws://localhost/ws/testNoti?订阅广播&发布广播&回音”的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:500 Websocket连接已断开 管理器配置文件 [unix_http_server] username = ubuntu password = password [program:uwsgi] command=/home/ubuntu/bxd-life/venv/bin/uwsgi --ini /home/ubuntu

我在犯错误

到“ws://localhost/ws/testNoti?订阅广播&发布广播&回音”的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:500

Websocket连接已断开

管理器配置文件

[unix_http_server]
username = ubuntu
password = password

[program:uwsgi]
command=/home/ubuntu/bxd-life/venv/bin/uwsgi --ini /home/ubuntu/bxd-life/bxd/bxd.ini
autostart=true
user=ubuntu
autorestart=true
stderr_logfile = /home/ubuntu/bxd-life/logs/err.log
stdout_logfile = /home/ubuntu/bxd-life/logs/out.log
stopsignal=INT

[program:uwsgi_ws]
command = /home/ubuntu/bxd-life/venv/bin/uwsgi --http :8080 --gevent 1000 --http-websockets --workers=2 --master --module bxd.wsgi_websockets
#directory=/home/ubuntu/bxd-life/bxd
autostart=true
autorestart=true
starttries=5
user=ubuntu
environment=DJANGO_SETTINGS_MODULE='bxd.settings'
upstream app_server {
            server localhost:8000;
    }
upstream web_socket_server {
    server localhost:8080 fail_timeout=0;
}
server {
    listen 80;
    server_name _;
    location /static/ {
        alias /home/ubuntu/bxd-life/bxd/static/;
        expires 30d;
    }

    location /ws/ {
            proxy_pass http://web_socket_server;
            proxy_http_version 1.1;
            #proxy_redirect ws://$server_name;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
    }

    location / {
            try_files $uri @proxy_to_app;
    }
    location @proxy_to_app {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass   http://app_server;
    }
  }
 }
nginx配置文件

[unix_http_server]
username = ubuntu
password = password

[program:uwsgi]
command=/home/ubuntu/bxd-life/venv/bin/uwsgi --ini /home/ubuntu/bxd-life/bxd/bxd.ini
autostart=true
user=ubuntu
autorestart=true
stderr_logfile = /home/ubuntu/bxd-life/logs/err.log
stdout_logfile = /home/ubuntu/bxd-life/logs/out.log
stopsignal=INT

[program:uwsgi_ws]
command = /home/ubuntu/bxd-life/venv/bin/uwsgi --http :8080 --gevent 1000 --http-websockets --workers=2 --master --module bxd.wsgi_websockets
#directory=/home/ubuntu/bxd-life/bxd
autostart=true
autorestart=true
starttries=5
user=ubuntu
environment=DJANGO_SETTINGS_MODULE='bxd.settings'
upstream app_server {
            server localhost:8000;
    }
upstream web_socket_server {
    server localhost:8080 fail_timeout=0;
}
server {
    listen 80;
    server_name _;
    location /static/ {
        alias /home/ubuntu/bxd-life/bxd/static/;
        expires 30d;
    }

    location /ws/ {
            proxy_pass http://web_socket_server;
            proxy_http_version 1.1;
            #proxy_redirect ws://$server_name;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
    }

    location / {
            try_files $uri @proxy_to_app;
    }
    location @proxy_to_app {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass   http://app_server;
    }
  }
 }
wsgi_websockets.py

 import os
 import gevent.socket
 import redis.connection

 redis.connection.socket = gevent.socket
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bxd.settings")
 from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
 application = uWSGIWebsocketServer()
上述功能在
/manage.py runserver
上运行良好,但在nginx上则不行

任何帮助都将不胜感激