Amazon web services AWS-未通过HTTPS连接的WebSocket
我在aws elastic beanstalk上部署了django web应用程序 我也在其中使用WebSocket ,我安装了应用程序负载平衡器,默认情况下它应该支持WebSocket 但是当建立连接(仅在HTTPS中)时,我收到了这个消息 在建立连接之前,WebSocket已关闭 HTTP没有问题,它工作得很好 下面是loadbalancer配置 以下是我在js中的连接方式Amazon web services AWS-未通过HTTPS连接的WebSocket,amazon-web-services,websocket,amazon-elastic-beanstalk,aws-load-balancer,daphne,Amazon Web Services,Websocket,Amazon Elastic Beanstalk,Aws Load Balancer,Daphne,我在aws elastic beanstalk上部署了django web应用程序 我也在其中使用WebSocket ,我安装了应用程序负载平衡器,默认情况下它应该支持WebSocket 但是当建立连接(仅在HTTPS中)时,我收到了这个消息 在建立连接之前,WebSocket已关闭 HTTP没有问题,它工作得很好 下面是loadbalancer配置 以下是我在js中的连接方式 const ws_path = 'wss://<IPv4 Public IP>:5000'; con
const ws_path = 'wss://<IPv4 Public IP>:5000';
const websocket = new ReconnectingWebSocket(ws_path,
null, {maxReconnectAttempts: 5, timeoutInterval: 5000});
和ssl_配置
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
ProxyRequests Off
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
文件:
“/etc/httpd/conf.d/ssl_rewrite.conf”:
模式:“000644”
所有者:root
组:根
内容:|
重新启动发动机
代理请求关闭
RewriteCond%{HTTP:UPGRADE}^WebSocket$[NC]
RewriteCond%{HTTP:CONNECTION}^升级$[NC]
重写规则(.*)https://%{HTTP_HOST}%{REQUEST_URI}[R,L]
您是否配置了http重定向到https?端口80到端口443?
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
ProxyRequests Off
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>