Django频道没有连接收到的404错误

时间:2016-09-09 03:42:48

标签: django apache redis django-deployment django-channels

我正在尝试将我的服务器从本地子网移到域中。主要网页正在运行,我将它们放在SSL后面。 Apache从任何HTTP连接到HTTPS都重写了url。但是,当我尝试使用以下命令从浏览器连接javascript时

new WebSocket("wss://" + window.location.host);

我收到以下错误:

WebSocket connection to 'wss://{MY_WEBSITE}.com/message_route/' failed: Error during WebSocket handshake: Unexpected response code: 404

我对settings.py的配置如下:

"default": {
    "BACKEND": "asgi_redis.RedisChannelLayer",
    "ROUTING": "my_app.routing.channel_routing",
    "Config": {
            "hosts": [os.environ.get('REDIS_URL', 'redis://127.0.0.0:6379')],
    }
},

编辑(加入APACHE配置数据):

我的Apache default.conf如下(简单重写为HTTPS):

<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>

Apache secure.conf:

<VirtualHost *:443>
    ServerName my_domain.com
    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile  /etc/ssl/my_domain/my_domain.crt
    SSLCertificateKeyFile /etc/ssl/my_domain/myserver.key
    SSLCACertificateFile /etc/ssl/my_domain/my_domain.ca-bundle

    Alias /static /home/user/my_app/myApp/static_files

    <Directory /home/user/my_app/myApp/static_files>
        Require all granted
    </Directory>

    <Directory /home/user/my_app/myApp/MyApp>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    WSGIDaemonProcess MyApp python-path=/home/user/my_app/myApp/MyApp
    WSGIProcessGroup MyApp
    WSGIScriptAlias / /home/user/my_app/myApp/MyApp/MyApp/wsgi.py
</VirtualHost>

编辑发现apache正在接收请求但没有做任何事情 我发布了other_vhosts.access.log并发现当我在chromes控制台中创建一个新的websocket时,apache记录了一个GET请求,但似乎没有将它转发到我的django应用程序。

我还有一个工作人员正在运行,一个redis服务器设置,以及daphne也在运行。如果您能想出任何可能解决此问题的方法,请告诉我

0 个答案:

没有答案
相关问题