我对 nginx 以及如何配置它来运行 channel 一无所知。我的环境是django 2.x
ubuntu 16
nginx
daphne
redis
digitalocean
我已经对我的 nginx 配置文件进行了数周的修改,现在无法连接我的套接字。
nginx 配置
server {
listen 80;
server_name x.x.x.x;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/admin1/myproject/channels-examples/multichat/static/ ;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/admin1/myproject/channels-examples/multichat/multichat.sock
}
}
我将不胜感激任何帮助。
最佳答案
您需要通过 daphne
运行您的应用(您可以在此处阅读更多信息:https://channels.readthedocs.io/en/latest/deploying.html)并为 websockets 连接配置相关的 nginx 部分:
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
关于django - 在 nginx 上部署 django channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52023012/