在AWS Application Load Balancer上同时运行两个不同端口的https://。

huangapple go评论101阅读模式
英文:

Running two different ports on the same https:// on AWS Application Load Balancer

问题

在同一台EC2实例上的一个ECS集群中,我正在运行两个容器:

第一个容器:一个在端口3000上运行的API,处理/a路径。
第二个容器:一个在端口5000上运行的gradio用户界面,处理/b路径。

通过应用负载均衡器,我将它们连接到一个带有SSL证书的网站(www.example.com),端口为443,以便https://www.example.com是有效的。

然而,我必须选择将我的监听器分配给EC2上的一个端口(要么3000,要么5000)。

是否有一种方法,也许可以使用规则,来连接这两个端口,使得可以访问:
https://www.example.com/ahttps://www.example.com/b

英文:

On one ECS cluster (on the same EC2), I am running two containers:

first container: one API working on :3000/a
second container: one gradio UI on port :5000/b

Through an Application Load Balancer, I am connecting them to a website (www.example.com) with an SSL certificate on port 443, so that the https://www.example.com is valid.

However, I have to choose to allocate my listener on port 443 to either one port on the EC2 (either 3000 or 5000).

Is there a way, perhaps using rules, to connect both ports to have:
https://www.example.com/a and https://www.example.com/b

答案1

得分: 2

是的,您可以使用ALB规则来实现这个目标:

首先,您需要创建两个目标组(例如A和B),一个用于端口3000,另一个用于端口5000。

如果您想要使用相同的域名但不同的路径,那么您可以在规则的IF子句中使用Path
如果您想让https://www.example.com/a指向端口3000,您的规则应该如下:IF Path is /a Forward to Target group A
如果您还可以添加一些附加项,比如查询字符串、参数,它们将通过相同的路径传递,您可以设置一个规则如下:IF Path is /a* Forward to Target Group A

然后,对于目标组B,执行相同的操作。

英文:

Yes, you can use ALB rules to achieve that:

First, you need to create 2 Target groups (A and B for example), one for port 3000 and the second for port 5000.

If you want to use the same domain name and different path, then you would use Path in the IF clause of the rule.
If you want https://www.example.com/a to go to port 3000, your rule would state IF Path is /a Forward to Target group A
If you can have some more additions, like query strings, parameters that will go through the same path, you would set a rule to be IF Path is /a* Forward to Target Group A

And then, do the same for Target group B.

答案2

得分: 1

创建两个目标组,第一个目标组到端口3000,第二个目标组到端口5000。之后,您可以设置基于路径的监听规则,其中路径为"a"然后重定向流量到第一个目标组,"b"则重定向到另一个目标组。

英文:

Create two target group, the first one to the port 3000 and the second one to the port 5000. After that, you can set the path based listener rule where the path is a then redirect traffic to the first target group and b for the other one.

huangapple
  • 本文由 发表于 2023年7月6日 18:56:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76628088.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定