小编san*_*rda的帖子

在https后面的django频道

Django-channels websocket在AWS服务器上运行良好,直到我安装了letsencript ssl.我尝试了另一个证书,但是wss无效.我看到这个在线部署显示渠道可以在https后面工作:

https://django-channels-example.herokuapp.com/

我跟着andrewgodwin sugestions在这里:

https://github.com/django/channels/issues/248

我把daphne指向了端口8000:

daphne -b 0.0.0.0 vp.asgi:channel_layer --port 8000 -v 2
Run Code Online (Sandbox Code Playgroud)

我在我的javascript中使用了相同的端口:

chatsock = new WebSocket( ws_scheme + '://' + window.location.host + ":8000/chat" );
Run Code Online (Sandbox Code Playgroud)

我的nginx配置:

server {
        listen 80;
        server_name mysite.com www.example.com;
        return 301 https://www.example.com$request_uri;
}

server{
        listen 443 ssl;
        server_name mysite.com www.example.com;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        root /home/ubuntu/vp;

        access_log /var/log/nginx/guni-access.log;
        error_log /var/log/nginx/guni-error.log info;

        location /wss/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_pass http://0.0.0.0:8000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection …
Run Code Online (Sandbox Code Playgroud)

python django ssl wss django-channels

6
推荐指数
1
解决办法
4162
查看次数

标签 统计

django ×1

django-channels ×1

python ×1

ssl ×1

wss ×1