1

我对 nginx 以及如何将其配置为运行频道一无所知。我的环境是django 2.x ubuntu 16 nginx daphne redis digitalocean我已经修改了我的 nginx 配置文件一个星期,现在无法让我的套接字连接。

nginx config

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

我将不胜感激任何帮助。

4

2 回答 2

0

我在我的非托管 VPS 上遇到了类似的问题。

当我弄清楚什么对我有用时,检查我创建的这个存储库。

您的静态位置:

location /static/ {
    alias /home/admin1/myproject/channels-examples/multichat/static/ ;
}

应该是这样的:

location /static {
    alias /home/admin1/myproject/channels-examples/multichat;
}
于 2018-10-25T14:09:36.063 回答
0

您需要运行您的应用程序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";
  }
于 2018-08-28T12:15:56.027 回答