Nginx设置
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.sample.co;
return 301 https://$host$request_uri;
}
server {
ssl on;
listen 443 ssl;
listen [::]:443 ssl;
server_name www.sample.co;
rewrite ^(.*) https://beta.sample.co$1 permanent;
ssl_certificate /home/ubuntu/certificate/certificate.crt;
ssl_certificate_key /home/ubuntu/certificate/private.key;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
在达芙妮上运行
CMD ["daphne","-b","0.0.0.0","-p","8001","config.asgi:application"]
工作正常
ws://xyz.amazonaws.com/ws/sample/<sample-id>/
无法继续工作
wss://xyz.amazonaws.com/ws/sample/<sample-id>/
错误:
WebSocket连接到
'wss://xyz.amazonaws.com/ws/sample//'失败:错误
建立连接:net :: ERR_CERT_COMMON_NAME_INVALID
这些应用程序正在AWS上运行。正在从https调用WebSocket。我试图从本地的虚拟React应用程序中使用
ws://
调用WebSocket,它工作正常。 最佳答案
我启用了CORS策略,该策略限制了连接到websocket。禁用后对我来说很好
关于javascript - Django channel 使用ws://,但无法与wss://握手,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58729291/