关于WebSocket/wss未连接,使用DjangoChannels和AWSElasticBeanstalk和未连接websocket服务器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关
关于WebSocket / wss 未连接,使用 Django Channels 和 AWS Elastic Beanstalk和未连接websocket服务器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于amazon-web-services – 为什么要为Docker使用AWS ECS与ElasticBeanstalk?、amazon-web-services – 从私有Docker存储库将映像部署到AWS Elastic Beanstalk、amazon-web-services – 在单个docker容器环境中配置nginx(AWS ElasticBeanstalk)、amazon-web-services – 如何使用Elastic beanstalk和Dockerrun.aws.json正确部署到AWS?等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- WebSocket / wss 未连接,使用 Django Channels 和 AWS Elastic Beanstalk(未连接websocket服务器)
- amazon-web-services – 为什么要为Docker使用AWS ECS与ElasticBeanstalk?
- amazon-web-services – 从私有Docker存储库将映像部署到AWS Elastic Beanstalk
- amazon-web-services – 在单个docker容器环境中配置nginx(AWS ElasticBeanstalk)
- amazon-web-services – 如何使用Elastic beanstalk和Dockerrun.aws.json正确部署到AWS?
WebSocket / wss 未连接,使用 Django Channels 和 AWS Elastic Beanstalk(未连接websocket服务器)
如何解决WebSocket / wss 未连接,使用 Django Channels 和 AWS Elastic Beanstalk?
在站点 https://yoga.sightica.com/class/
控制台收到此 webSocket 错误。后端 Django 并使用 elastic beanstalk 部署在 AWS 中。
Firefox 无法与 wss://yoga.sightica.com/class/ 上的服务器建立连接。
main.js:76:16
或在谷歌浏览器中
main.js:76 WebSocket 连接到“wss://yoga.sightica.com/class/”失败: (匿名)@main.js:76
这是我的 main.js 文件第 76 行
webSocket = new WebSocket(endPoint);
我已经使用他们的官方文档配置了 Django 通道和 Redis 弹性缓存。
option_settings:
aws:elbv2:listener:80:
DefaultProcess: http
ListenerEnabled: ''true''
Protocol: HTTP
Rules: ws
aws:elbv2:listener:443:
ListenerEnabled: ''true''
Protocol: HTTPS
SSLCertificateArns: <substituted my ARN FROM AWS CERTIFICATES MANAGER>
SSLPolicy: ELBSecurityPolicy-2016-08
Rules: ws
aws:elbv2:listenerrule:ws:
PathPatterns: /ws/*
Process: websocket
Priority: 1
aws:elasticbeanstalk:environment:process:http:
Port: ''80''
Protocol: HTTP
aws:elasticbeanstalk:environment:process:websocket:
Port: ''5000''
Protocol: HTTP
这是我的弹性豆茎配置。我需要一个合适的 .config 文件,其他配置教程没有为我部署在 elastic beanstalk 中。
我用过这个procfile(替代了我的路径)
web: gunicorn --bind :8000 --workers 3 --threads 2 <your_app>.wsgi:application
websocket: daphne -b 0.0.0.0 -p 5000 <your_app>.asgi:application
我需要在 HTTPS 页面中获取 websocket,因为我需要访问网络摄像头。 并且 websocket 在 localhost 中工作。
( WebSocket() 函数可以在这里看到 https://developer.mozilla.org/en-US/docs/Web/API/WebSocket )
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
amazon-web-services – 为什么要为Docker使用AWS ECS与ElasticBeanstalk?
我打算使用Docker,并将1个EC2实例与1个Microservice相关联.
为什么我要在AWS ECS和ElasticBeanstalk中部署Docker?
据说AWS ECS对Docker有本机支持.是吗?
如果你能详细说明在AWS ECS和ElasticBeanstalk上运行docker的优缺点,那就太棒了.
>自动与ECS和ELB交互
>群集运行状况和指标随时可用,无需任何额外工作即可显示
>负载均衡器必须终止HTTPS,所有后端连接都是HTTP
>可轻松调整自动调节和实例大小
>容器日志全部收集在一个地方,但仍按实例分段 – 因此在集群环境中查找哪个实例服务于记录某些重要数据的请求是一项挑战.
>只能在容器定义中设置硬内存限制
>所有集群实例必须运行相同的容器集
从ECS开始,IT是亚马逊对容器编排的回答.它的边缘有点粗糙,绝对是Elastic Beanstalk的一个飞跃,但它确实具有更大的灵活性,包括甚至可以定义自定义调度程序.
Elastic Beanstalk强加的所有限制都被取消了.
请参阅以下更多信息:
Elastic Beanstalk vs. ECS vs. Kubernetes
Amazon EC2 Container Serivce
Amazon Elasticbeanstalk
amazon-web-services – 从私有Docker存储库将映像部署到AWS Elastic Beanstalk
我正在尝试从其私有仓库中提取Docker镜像,并在Zip包装的Dockerrun.aws.json的帮助下将其部署在AWS Elastic Beanstalk上.它的内容是
{
"AWSEBDockerrunVersion": "1","Authentication": {
"Bucket": "my-bucket","Key": "docker/.dockercfg"
},"Image": {
"Name": "namespace/repo:tag","Update": "true"
},"Ports": [
{
"ContainerPort": "8080"
}
]
}
其中“my-bucket”是我在s3上的桶名,它使用与我的BS环境相同的位置.在密钥中设置的配置是结果
$docker login
在docker2boot应用程序的终端中调用.然后将其复制到“my-bucket”中的文件夹“docker”.图像确实存在.
之后我将带有dockerrun文件的.zip上传到EB,然后部署我得到
Activity execution Failed,because: WARNING: Invalid auth configuration file
我错过了什么?
提前致谢
但是,AWS仍然需要前一种格式,即〜/ .dockercfg(see the file name in their documentation)中使用的格式:
{
"https://index.docker.io/v1/": {
"auth": "__auth__","email": "__email__"
}
}
这与〜/ .docker / config.json中使用的新格式不兼容:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "__auth__","email": "__email__"
}
}
}
它们非常相似.因此,如果您的Docker版本生成新格式,只需删除auths行及其相应的大括号,您就可以了.
amazon-web-services – 在单个docker容器环境中配置nginx(AWS ElasticBeanstalk)
我目前正在使用AWS ElasticBeanstalk中的single container docker environment部署Django uWsgi应用程序.这个环境已经附带了Nginx,我目前正在尝试配置它.
我想要实现以下目标:
>在环境的负载均衡器处终止HTTPS
>使用Nginx(随环境提供)将HTTP请求重定向到HTTPS
>将请求从Nginx传递给uwsgi
环境信息:
>配置和解决方案堆栈名称:单容器Docker 1.11
版本2.3.0
> AMI:运行Docker的64位Amazon Linux 2016.09 v2.3.0
1.11.2
2016.09.0
> Docker版本:1.11.2
>代理服务器:Nginx 1.10.1
这是我目前的配置:
.ebxtensions / 00-负载均衡器-terminatehttps.config
option_settings:
aws:elb:listener:443:
ListenerEnabled: true
ListenerProtocol: HTTPS
SSLCertificateId: <resource-id-here>
InstancePort: 443
InstanceProtocol: HTTP
aws:elb:listener:80:
ListenerEnabled: true
ListenerProtocol: HTTP
InstancePort: 80
InstanceProtocol: HTTP
.ebextensions / 01-Nginx的-proxy.config
files:
"/etc/Nginx/sites-available/test.domain.com.conf":
mode: "000644"
owner: root
group: root
content: |
server {
listen 80;
server_name test.domain.com;
access_log /var/log/Nginx/$server_name.access.log;
location / {
return 301 https://$server_name$request_uri;
}
location = /status/ {
access_log /var/log/Nginx/$server_name.healthd.log healthd;
include uwsgi_params;
uwsgi_pass docker;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
}
}
server {
listen 443;
server_name test.domain.com;
access_log /var/log/Nginx/$server_name.access.log;
location / {
include uwsgi_params;
uwsgi_pass docker;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
client_max_body_size 100m;
}
location /static {
alias /var/www/static;
}
}
commands:
00_enable_site:
command: 'rm -f /etc/Nginx/sites-enabled/* && ln -s /etc/Nginx/sites-available/test.domain.com.conf /etc/Nginx/sites-enabled/test.domain.com.conf'
.ebextensions / 02-healthcheckurl.config
option_settings:
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /status/
application.ini(uwsgi config)
[uwsgi]
master = true
socket = :3031
processes = 4
enable-threads = true
threads = 2
chdir = /opt/app/
wsgi-file = test/wsgi.py
logto2 = /var/log/uwsgi.log
callable = application
py-autoreload = 3
现在,在测试配置时:
检查http://test.domain.com/status/工作正常
$wget http://test.domain.com/status/
--2017-01-14 23:00:18-- http://test.domain.com/status/
Resolving test.domain.com... 52.xx.xx.xx, 52.xx.xx.xy
Connecting to test.domain.com|52.xx.xx.xx|:80... connected.
HTTP request sent, awaiting response... 200 OK
检查http://test.domain.com/hello/无法按预期工作.它重定向很好,但它会挂起,直到请求超时.
$wget http://test.domain.com/hello/
--2017-01-14 22:59:13-- http://test.domain.com/hello/
Resolving test.domain.com... 52.xx.xx.xx, 52.xx.xx.xy
Connecting to test.domain.com|52.xx.xx.xx|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://test.domain.com/hello/ [following]
--2017-01-14 22:59:15-- https://test.domain.com/hello/
Connecting to test.domain.com|52.xx.xx.xx|:443... connected.
HTTP request sent, awaiting response... 408 REQUEST_TIMEOUT
2017-01-14 23:00:17 ERROR 408: REQUEST_TIMEOUT.
解决方法:
根据@ deviavir的建议,我需要允许来自负载均衡器的流量进入EC2实例.
这是我的最终配置:
.ebextensions
|-- 00-resources.config
|-- 01-Nginx-proxy.config
.ebextensions / 00-resources.config:
Resources:
AWSEBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Allow traffic to ports 80 and 443 from the load balancer. Restrict SSH access."
AWSEBLoadBalancer:
Type: "AWS::ElasticLoadBalancing::LoadBalancer"
Properties:
Listeners:
- {LoadBalancerPort: 80,
Protocol: 'HTTP',
InstancePort: 80,
InstanceProtocol: 'HTTP'}
- {LoadBalancerPort: 443,
Protocol: 'HTTPS',
InstancePort: 443,
InstanceProtocol: 'HTTP',
SSLCertificateId: 'arn:aws:acm:us-east-1:xxxx:certificate/yyyy'}
HealthCheck:
Target: HTTP:80/status/
HealthyThreshold: '3'
UnhealthyThreshold: '5'
Interval: '30'
Timeout: '5'
port80SecurityGroupIngress:
Type: "AWS::EC2::SecurityGroupIngress"
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 80
FromPort: 80
SourceSecurityGroupName: {"Fn::GetAtt" : ["AWSEBLoadBalancer" , "SourceSecurityGroup.GroupName"]}
Port443SecurityGroupIngress:
Type: "AWS::EC2::SecurityGroupIngress"
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
FromPort: 443
SourceSecurityGroupName: {"Fn::GetAtt" : ["AWSEBLoadBalancer" , "SourceSecurityGroup.GroupName"]}
SSHSecurityGroupIngress:
Type: "AWS::EC2::SecurityGroupIngress"
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 22
FromPort: 22
CidrIp: xx.xx.xx.xx/yy
.ebextensions / 01-Nginx的-proxy.config:
files:
"/etc/Nginx/sites-available/test.domain.com.conf":
mode: "000644"
owner: root
group: root
content: |
server {
listen 80;
server_name test.domain.com;
access_log /var/log/Nginx/$server_name.access.log;
location / {
return 301 https://$server_name$request_uri;
}
location = /status/ {
access_log /var/log/Nginx/$server_name.status.log;
uwsgi_pass docker;
include uwsgi_params;
}
}
server {
listen 443;
server_name test.domain.com;
access_log /var/log/Nginx/$server_name.access.log;
location / {
uwsgi_pass docker;
include uwsgi_params;
client_max_body_size 100m;
}
location /static/ {
root /var/www;
}
}
commands:
00_enable_site:
command: 'rm -f /etc/Nginx/sites-enabled/* && ln -s /etc/Nginx/sites-available/test.domain.com.conf /etc/Nginx/sites-enabled/test.domain.com.conf'
amazon-web-services – 如何使用Elastic beanstalk和Dockerrun.aws.json正确部署到AWS?
我目前有一个本地工作的docker镜像,并在hub.docker.com上私下托管.
在容器内我有导轨,美洲狮,Nginx. Elastic beanstalk能够从docker hub成功提取映像,但之后无法执行任何操作.
AWS有Nginx并且正在返回此错误.有谁能够指出我做错了什么?
AWS错误日志
-------------------------------------
/var/log/Nginx/error.log
-------------------------------------
2014/12/27 08:48:34 [emerg] 3161#0: no host in upstream ":80" in /etc/Nginx/conf.d/elasticbeanstalk-Nginx-docker-upstream.conf:2
更多AWS错误日志
Nginx: [emerg] no host in upstream ":80" in /etc/Nginx/conf.d/elasticbeanstalk-Nginx- docker-upstream.conf:2
Nginx: configuration file /etc/Nginx/Nginx.conf test Failed
Failed to start Nginx, abort deployment (Executor::NonZeroExitStatus)
at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/executor-1.0/lib/executor/exec.rb:81:in `sh'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/executor-1.0/lib/executor.rb:15:in `sh'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/executable.rb:63:in `execute!'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/hook-directory-executor.rb:29:in `block (2 levels) in run!'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/activity.rb:169:in `call'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/activity.rb:169:in `exec'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/activity.rb:126:in `timeout_exec'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/activity.rb:110:in `block
src文件的错误
upstream docker {
server :80;
keepalive 256;
}
这是我的文件.
Dockerfile
FROM ruby:2.1.5
#################################
# native libs
#################################
RUN apt-get update -qq
RUN apt-get install -qq -y build-essential
RUN apt-get install -qq -y libpq-dev
RUN apt-get install -qq -y nodejs
RUN apt-get install -qq -y npm
RUN apt-get install -qq -y Nginx
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#################################
# Install Nginx.
#################################
RUN echo "\ndaemon off;" >> /etc/Nginx/Nginx.conf
RUN chown -R www-data:www-data /var/lib/Nginx
ADD config/Nginx.conf /etc/Nginx/sites-enabled/default
EXPOSE 80
#################################
# Symlinking Nodejs for ubuntu
# -- https://stackoverflow.com/questions/26320901/cannot-install-nodejs-usr-bin-env-node-no-such-file-or-directory
#################################
RUN ln -s /usr/bin/nodejs /usr/bin/node
#################################
# NPM install globals
#################################
RUN npm install bower -g
#################################
# Rails
#################################
RUN mkdir /app
workdir /app
ADD . /app
ENV RAILS_ENV production
ENV SECRET_KEY_BASE test123
RUN bundle install --without development test
RUN bundle exec rake bower:install
RUN bundle exec rake assets:precompile
CMD foreman start -f procfile
Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Authentication": {
"Bucket": "aws-bucket",
"Key": ".dockercfg"
},
"Image": {
"Name": "ericraio/my-image",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80"
}
],
"Logging": "/var/log/Nginx"
}
Nginx
upstream rails_app {
server unix:///app/tmp/sockets/puma.sock fail_timeout=0;
}
server {
# listen 80 deferred;
# server_name domain.tld www.domain.tld;
root /app/public;
try_files $uri/index.html $uri @rails_app;
location @rails_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://rails_app;
}
error_page 500 504 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
解决方法:
问题是在EC2上容器无法运行. Amazon使用此命令构建IP地址并设置环境变量.
EB_CONfig_Nginx_UPSTREAM_IP=$(docker inspect `cat $EB_CONfig_DOCKER_STAGING_APP_FILE` | jq -r .[0].NetworkSettings.IPAddress)
然后亚马逊使用此行来构建IP地址.
EB_CONfig_Nginx_UPSTREAM_PORT=`cat $EB_CONfig_DOCKER_STAGING_PORT_FILE`
我暴露了我的端口80,但因为我的容器无法运行我没有主机.这就是你得到这个错误的原因.
上游没有主机“:80”
今天关于WebSocket / wss 未连接,使用 Django Channels 和 AWS Elastic Beanstalk和未连接websocket服务器的分享就到这里,希望大家有所收获,若想了解更多关于amazon-web-services – 为什么要为Docker使用AWS ECS与ElasticBeanstalk?、amazon-web-services – 从私有Docker存储库将映像部署到AWS Elastic Beanstalk、amazon-web-services – 在单个docker容器环境中配置nginx(AWS ElasticBeanstalk)、amazon-web-services – 如何使用Elastic beanstalk和Dockerrun.aws.json正确部署到AWS?等相关知识,可以在本站进行查询。
本文标签: