频道 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
我 运行 在我安装并将“频道”添加到设置然后添加到 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