在Elastic Beanstalk Docker容器上运行非www的东西 [英] Running non-www stuff on an Elastic Beanstalk Docker container

查看:198
本文介绍了在Elastic Beanstalk Docker容器上运行非www的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Elastic Beanstalk的Docker容器上运行一个SMTP服务器,所以在我的Docker文件中我已经暴露了端口25(而没有其他端口)

I want to run a SMTP server on a Docker container in Elastic Beanstalk, so in my Dockerfile I have exposed the port 25 (and no other ports)

EXPOSE 25

我还编辑了beanstalk负载平衡器(使用EC2 web admin)并添加了端口25:

I also edited the beanstalk load balancer (using EC2 web admin) and added port 25 to it:

| LB Protocol | LB Port | Instance Protocol | Instance Port | SSL |
|    TCP      |   25    |        TCP        |        25     | N/A |
....

并编辑实例的安全组,以允许入站TCP流量到端口25(允许所有位置都能够直接连接到实例)。

And edited the security group of the instance to allow inbound TCP traffic to port 25 (allowed all locations to be able to connect to the instance directly).

似乎没有工作。如果我在Virtualbox中使用相同的Docker文件(使用选项 -p 25:25 ),我可以通过主机连接到端口25,SMTP服务器正在监听。如果我使用上述配置运行Elastic Beanstalk中的容器,则无法连接到端口25,既不使用负载平衡器,也不能直接使用EC2实例。

Doesn't seem to work though. If I use the same Dockerfile in Virtualbox (using option -p 25:25) I can connect to the port 25 through the host machine and the SMTP server is listening. If I run the container in Elastic Beanstalk using the before-mentioned configuration I can't connect to the port 25 neither using the load balancer or directly the EC2 instance.

想法我在这里做错什么?

Any ideas what I'm doing wrong here?

推荐答案

而不是直接从EC2网页管理员编辑负载平衡器配置,建议您使用elasticbeanstalk ebextensions,因为即使您的自动缩放组中的EC2实例被替换,您的环境也会持续存在。

Instead of editing the Load Balancer configuration directly from EC2 web admin it is recommended you do it using elasticbeanstalk ebextensions because those changes persist for your environment even if your EC2 instances in the auto-scaling group are replaced.

您可以尝试以下操作吗?
在您的应用程序来源中,在名为 .ebextensions 的文件夹中创建一个文件01-elb.config,内容如下:

Can you try the following? Create a file "01-elb.config" in a folder called .ebextensions in your app source with the following contents:

option_settings:
    - namespace: aws:cloudformation:template:parameter
      option_name: InstancePort
      value: 25

Resources:
    AWSEBLoadBalancer:
        Type: AWS::ElasticLoadBalancing::LoadBalancer
        Properties:
            Listeners:
                - InstancePort: 25
                  LoadBalancerPort: 80
                  Protocol: TCP
                - InstancePort: 25
                  LoadBalancerPort: 25
                  Protocol: TCP
            AvailabilityZones:
                - us-west-2a
                  us-west-2b
                  us-west-2c
            HealthCheck:
                Timeout: 5
                Target: TCP:25
                Interval: 30
                HealthyThreshold: 3
                UnhealthyThreshold: 5

此文件采用YAML格式,因此缩进很重要。
选项设置('aws:cloudformation:template:parameter','InstancePort')将实例端口设置为25,还会修改安全组,以确保端口25可由负载平衡器访问。

This file is in YAML format and hence indentation is important. The option setting ('aws:cloudformation:template:parameter', 'InstancePort') sets the instance port to 25 and also modifies the security group to make sure that port 25 is accessible by the load balancer.

此文件覆盖由弹性Beanstalk创建的默认负载平衡器资源,其中两个监听器都将实例端口设置为25.希望有助于。

This file is overriding the default Load Balancer Resource created by Elastic Beanstalk with two listeners both having instance port set to 25. Hope that helps.

阅读有关使用ebextensions自定义环境的更多信息 here
您可以尝试在appsource目录中的 .ebextensions / 01-elb.config 文件中创建具有上述文件的新环境?如果遇到任何问题,请告诉我。

Read more about customizing your environment with ebextensions here. Can you try creating a new environment with the above file in .ebextensions/01-elb.config file in the appsource directory? Let me know if you run into any issues.

这篇关于在Elastic Beanstalk Docker容器上运行非www的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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