【发布时间】:2017-11-18 01:09:08
【问题描述】:
我有一个 Django 项目,它在我的 VPS over apache 上运行良好。 将 Django 频道添加到我的项目后,它可以在 localhost 上完美运行,但在我的 vps 中,我的浏览器记录了一个错误“WebSocket connection to '...' failed: Error during WebSocket handshake: Unexpected response code: 404”并且项目失败了。
根据我的谷歌搜索,我认为 apache 不支持 web-socket。但在 apache 上运行频道时找不到明确的答案和行程
这是我在 000-default.conf 中的 apache 配置:
<VirtualHost *:80>
Alias /static /opt/kalameh/static
<Directory /opt/kalameh/static>
Require all granted
</Directory>
<Directory /opt/kalameh/server>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess kalameh python-path=opt/kalameh python-home=opt/kalameh/kalamehenv
WSGIProcessGroup kalameh
WSGIScriptAlias / opt/kalameh/server/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
这是我的 wsgi.py
import os
import sys
sys.path.append('/opt/kalameh/')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
application = get_wsgi_application()
【问题讨论】:
-
我猜你必须将你的域名/IP地址添加到CHANNEL_LAYERS -> CONFIG -> hosts
-
我试试这个但没有解决我的问题
标签: django apache django-channels