在弹性Beanstalk中暴露Docker的多个端口 [英] Exposing multiple ports from Docker within Elastic Beanstalk

查看:254
本文介绍了在弹性Beanstalk中暴露Docker的多个端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从阅读AWS文档看,当使用Docker作为Elastic Beanstalk(EB)(而不是Tomcat等)的平台时,只能显示一个端口。我试图理解为什么亚马逊创建了这个限制 - 似乎你现在甚至不能同时服务于HTTP和HTTPS。



我想使用Docker该容器因为它允许我在同一容器内运行多个互连的服务器进程,其中一些需要多个端口(例如RTSP)。这种应用程序有什么解决方法,其中RTSP和HTTP服务器都可以在EB上的同一Docker容器中运行?

解决方案

您可以为Elastic Beanstalk的LoadBalancer / ReversProxy编写一个启动配置文件,以将其他端口转发到其EC2实例。 Ben Delarre 的示例:

 资源:{
AWSEBLoadBalancerSecurityGroup:{
Type:AWS :: EC2 :: SecurityGroup,
属性:{
GroupDescription:启用80入站和8080出站,
VpcId:vpc-un1que1d,
SecurityGroupIngress:[{
IpProtocol:tcp,
FromPort:80,
ToPort:80,
CidrIp:0.0.0.0/0
$]
SecurityGroupEgress:[{
IpProtocol:tcp,
FromPort:8080,
ToPort:8080
CidrIp:0.0.0.0/0
}]
}
},
AWSEBLoadBalancer:{
Type: AWS :: ElasticLoadBalancing :: LoadBalancer,
属性:{
子网:[subnet-un1que1d2],
侦听器:[{
LoadBalancerPort :80,
InstancePort:8080,
协议:HTTP
}]
}
}
}

参考:




From reading the AWS documentation, it appears that when using Docker as the platform on Elastic Beanstalk (EB) (as opposed to Tomcat, etc.), only a single port can be exposed. I'm trying to understand why Amazon created this restriction -- seems that you now can't even serve both HTTP and HTTPS.

I'd like to use Docker as the container since it allows me to run several interconnected server processes within the same container, some of which require multiple ports (e.g. RTSP). Are there any workarounds for this kind of application, where say an RTSP and HTTP server can both be running within the same Docker container on EB?

解决方案

You could write an on-start config file for Elastic Beanstalk's LoadBalancer/ReversProxy to forward the additional ports to its EC2 instance(s). an example from Ben Delarre :

"Resources" : {
  "AWSEBLoadBalancerSecurityGroup": {
    "Type" : "AWS::EC2::SecurityGroup",
    "Properties" : {
      "GroupDescription" : "Enable 80 inbound and 8080 outbound",
      "VpcId": "vpc-un1que1d",
      "SecurityGroupIngress" : [ {
        "IpProtocol" : "tcp",
        "FromPort" : "80",
        "ToPort" : "80",
        "CidrIp" : "0.0.0.0/0"
      }],
      "SecurityGroupEgress": [ {
        "IpProtocol" : "tcp",
        "FromPort" : "8080",
        "ToPort" : "8080",
        "CidrIp" : "0.0.0.0/0"
      } ]
    }
  },
  "AWSEBLoadBalancer" : {
    "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
    "Properties" : {
      "Subnets": ["subnet-un1que1d2"],
      "Listeners" : [ {
        "LoadBalancerPort" : "80",
        "InstancePort" : "8080",
        "Protocol" : "HTTP"
      } ]
    }
  }
}

Ref:

这篇关于在弹性Beanstalk中暴露Docker的多个端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆