Deploying Django Channels for secured WebSocket(wss) connection on Apache server

杀马特。学长 韩版系。学妹 提交于 2020-02-04 03:38:06

问题


Need help in configuring secured WebSocket connection in windows server machine for Apache.

Please check below for .conf files,

httpd-vhost.conf:

Listen 8080
WSGIPythonPath "D:/django_project/"
<VirtualHost 10.66.88.87:8080>

    ServerName test.company.com
    ServerAlias test.company.com
    ServerAdmin xxxx.xxxx@company.com
    SSLEngine on
    SSLCertificateFile "D:/django_project/cert/certificate.cert"
    SSLCertificateKeyFile "D:/django_project/cert/privatekey.key"

    WSGIScriptAlias / "D:/django_project/django_project/wsgi.py"
    DocumentRoot "D:/django_project/"

    <Directory "D:/django_project/">
      <Files wsgi.py>
         AllowOverride All
         Require all granted
      </Files>
    </Directory>

    <Directory "D:/django_project/app/static">
        Require all granted
    </Directory>
    Alias /static "D:/django_project/app/static"

    ProxyRequests Off 
    ProxyPass /wss/  ws://10.66.88.87:8080   

    ErrorLog "D:/django_project/log/error.log"
    CustomLog "D:/django_project/log/access.log" common
</VirtualHost>

httpd-ssl.conf:

<VirtualHost _default_:443>

#   General setup for the virtual host
DocumentRoot "${SRVROOT}/htdocs"
ServerName www.example.com:443
ServerAdmin admin@example.com
ErrorLog "${SRVROOT}/logs/error.log"
TransferLog "${SRVROOT}/logs/access.log"

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
....
....
.... # this file don't have changes

Apache error log:

[Sat Nov 09 14:45:04.654465 2019] [mpm_winnt:notice] [pid 145260:tid 712] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Nov 09 14:45:06.686147 2019] [mpm_winnt:notice] [pid 117948:tid 660] AH00364: Child: All worker threads have exited.
[Sat Nov 09 14:45:07.938036 2019] [mpm_winnt:notice] [pid 145260:tid 712] AH00430: Parent: Child process 117948 exited successfully.
[Sat Nov 09 14:45:10.563900 2019] [ssl:warn] [pid 147168:tid 708] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:45:10.715008 2019] [ssl:warn] [pid 147168:tid 708] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:45:10.718010 2019] [mpm_winnt:notice] [pid 147168:tid 708] AH00455: Apache/2.4.39 (Win64) OpenSSL/1.1.1b mod_wsgi/4.5.24 Python/3.6 configured -- resuming normal operations
[Sat Nov 09 14:45:10.719011 2019] [mpm_winnt:notice] [pid 147168:tid 708] AH00456: Apache Lounge VC15 Server built: Mar 28 2019 11:59:33
[Sat Nov 09 14:45:10.719011 2019] [core:notice] [pid 147168:tid 708] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Sat Nov 09 14:45:10.843098 2019] [mpm_winnt:notice] [pid 147168:tid 708] AH00418: Parent: Created child process 48800
[Sat Nov 09 14:45:12.442235 2019] [ssl:warn] [pid 48800:tid 648] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:45:12.702419 2019] [ssl:warn] [pid 48800:tid 648] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:45:13.076684 2019] [mpm_winnt:notice] [pid 48800:tid 648] AH00354: Child: Starting 64 worker threads.
[Sat Nov 09 14:48:25.784540 2019] [mpm_winnt:notice] [pid 147168:tid 708] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Nov 09 14:48:55.829806 2019] [mpm_winnt:notice] [pid 147168:tid 708] AH00431: Parent: Forcing termination of child process 48800
[Sat Nov 09 14:49:00.749300 2019] [ssl:warn] [pid 121264:tid 704] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:03.883524 2019] [ssl:warn] [pid 121264:tid 704] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:03.887527 2019] [mpm_winnt:notice] [pid 121264:tid 704] AH00455: Apache/2.4.39 (Win64) OpenSSL/1.1.1b mod_wsgi/4.5.24 Python/3.6 configured -- resuming normal operations
[Sat Nov 09 14:49:03.887527 2019] [mpm_winnt:notice] [pid 121264:tid 704] AH00456: Apache Lounge VC15 Server built: Mar 28 2019 11:59:33
[Sat Nov 09 14:49:03.887527 2019] [core:notice] [pid 121264:tid 704] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Sat Nov 09 14:49:04.016619 2019] [mpm_winnt:notice] [pid 121264:tid 704] AH00418: Parent: Created child process 86184
[Sat Nov 09 14:49:05.008324 2019] [ssl:warn] [pid 86184:tid 656] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:05.110395 2019] [ssl:warn] [pid 86184:tid 656] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:05.230480 2019] [mpm_winnt:notice] [pid 86184:tid 656] AH00354: Child: Starting 64 worker threads.

Project error log:

[Sat Nov 09 14:49:00.752302 2019] [ssl:warn] [pid 121264:tid 704] AH01906: test.company.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sat Nov 09 14:49:00.752302 2019] [ssl:warn] [pid 121264:tid 704] AH01909: test.company.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:03.886526 2019] [ssl:warn] [pid 121264:tid 704] AH01906: test.company.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sat Nov 09 14:49:03.886526 2019] [ssl:warn] [pid 121264:tid 704] AH01909: test.company.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:05.012326 2019] [ssl:warn] [pid 86184:tid 656] AH01906: test.company.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sat Nov 09 14:49:05.012326 2019] [ssl:warn] [pid 86184:tid 656] AH01909: test.company.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:05.113398 2019] [ssl:warn] [pid 86184:tid 656] AH01906: test.company.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sat Nov 09 14:49:05.113398 2019] [ssl:warn] [pid 86184:tid 656] AH01909: test.company.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 09 14:49:09.297369 2019] [wsgi:error] [pid 86184:tid 1308] [client 10.66.88.87:59493]  262steja6x8ru2lxd3xs6q1v9i4pjm8\r, referer: https://10.66.88.87:8080/

Error in the browser(chrome):

(index):194 WebSocket connection to 'wss://10.66.88.87:8080/ws/home/' failed: Error during WebSocket handshake: Unexpected response code: 404

Any kind of hint/suggestion(even links which subject this) to debug is highly appreciated.

来源:https://stackoverflow.com/questions/58778048/deploying-django-channels-for-secured-websocketwss-connection-on-apache-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!