簡體   English   中英

頻道 django nginx 502

[英]Channels django nginx 502

我在安裝並將“頻道”添加到設置中,然后添加到 asgi 文件后遇到了問題。 服務器崩潰,我得到 502 和 nginx 無法啟動。 我怎樣才能添加這些頻道並開始工作

ASGI_APPLICATION = "mysite.asgi.application"

application = ProtocolTypeRouter({
"http": get_asgi_application(),
# Just HTTP for now. (We can add other protocols later.)
# WebSocket chat handler
"websocket": AuthMiddlewareStack(
    URLRouter([
        
    ])
),

})

求助,相信很多人都遇到過,謝謝

您是否正確配置了 Nginx? 以下是示例 Nginx 配置。

upstream channels-backend {
    server localhost:8000;
}
...
server {
    ...
    location / {
        try_files $uri @proxy_to_app;
    }
    ...
    location @proxy_to_app {
        proxy_pass http://channels-backend;

        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;
    }
    ...
}

請在此處查看部署指南: https://channels.readthedocs.io/en/latest/deploying.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM