【发布时间】:2020-03-02 21:16:32
【问题描述】:
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。我尝试从本地的虚拟反应应用程序中使用 ws:// 调用 WebSocket,它工作正常。
【问题讨论】:
标签: javascript django amazon-web-services websocket django-channels