一旦我安裝并將“頻道”添加到設定中,然后添加到 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([
])
),
})
求助,相信很多人都遇到過,謝謝
uj5u.com熱心網友回復:
您是否正確配置了 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
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/474905.html
標籤:django nginx django 频道 http-status-code-502
下一篇:Nginx配置以在URI前綴下為Angular應用程式提供服務,其中檔案在與“index.html”相同的檔案夾中生成
