[英]Channels django nginx 502
I ran into a problem once I install and add "channels" to the settings and after that to the asgi file.我在安装并将“频道”添加到设置中,然后添加到 asgi 文件后遇到了问题。 Server crashes, I get 502 and nginx won't start.服务器崩溃,我得到 502 和 nginx 无法启动。 How can I add these channels and start working already我怎样才能添加这些频道并开始工作
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([
])
),
}) })
help, I'm sure a lot of people have come across this, thanks求助,相信很多人都遇到过,谢谢
Did you configure Nginx properly?您是否正确配置了 Nginx? Below is a sample Nginx config.以下是示例 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;
}
...
}
See the deployment guide here: https://channels.readthedocs.io/en/latest/deploying.html请在此处查看部署指南: https://channels.readthedocs.io/en/latest/deploying.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.