简体   繁体   English

如何将在 Route 53 中创建的 Map 子域用于在具有不同端口的 EC2 实例中运行的应用程序

[英]How to Map Sub Domains created in Route 53 to application running in EC2 instance with different port

I have springboot application with different ports hosted in ec2 instance Domain in Route 53我在 Route 53 的 ec2 实例域中托管了具有不同端口的 springboot 应用程序

Domain Name: mydomain.com域名:mydomain.com

App A - 8081, App B - 8085, App c - 8088应用 A - 8081,应用 B - 8085,应用 c - 8088

Instance IP: 10.xx.xx.xx实例 IP:10.xx.xx.xx

domain: test1.mydomain.com point to 10.xx.xx.xx:8081/landingpage &域:test1.mydomain.com 指向 10.xx.xx.xx:8081/landingpage &

test2.mydomain.com point to 10.xx.xx.xx:8085/landingpage & test3.mydomain.com point to 10.xx.xx.xx:8088/landingpage test2.mydomain.com 指向 10.xx.xx.xx:8085/landingpage & test3.mydomain.com 指向 10.xx.xx.xx:8088/landingpage

I have some idea in creating Load Balancer and Target Groups in beginner level.我对在初学者级别创建负载均衡器和目标组有一些想法。 Your views are always welcome.随时欢迎您的意见。

Route53 is DNS web service. Route53 是 DNS 网络服务。 It only resolves names to IP addresses, not ports nor URL paths.它仅将名称解析为 IP 地址,而不是端口或 URL 路径。 For that you need to either setup a load balancer for your instance, or using nginx on the instance to manage ports and url path redirections.为此,您需要为您的实例设置负载均衡器,或者在实例上使用 nginx 来管理端口和 url 路径重定向。

As stated by Marcin, Route53 can't resolve port, this is a walk around.. Assuming you already open two ports on your ec2 instance.正如 Marcin 所说,Route53 无法解析端口,这是四处走走。假设您已经在 ec2 实例上打开了两个端口。

  1. Create 2 target groups.创建 2 个目标组。 One to port 8085, one to port 8088. Register your instance to those 2 target groups一个到端口 8085,一个到端口 8088。将您的实例注册到这 2 个目标组
  2. Create application load balancer (ALB).创建应用程序负载均衡器 (ALB)。 Create 2 CNAME record with subdomain as your need, route both to your ALB DNS根据需要使用子域创建 2 个 CNAME 记录,将两者路由到您的 ALB DNS
  3. Optional: Create a certificate for your domain (ACM), it should able ssl on *.mydomain.com, register the certificate to your HTTPS load balancer.可选:为您的域 (ACM) 创建一个证书,它应该能够在 *.mydomain.com 上使用 ssl,将证书注册到您的 HTTPS 负载均衡器。
  4. Create listening rule on port 443 of your ALB (80 if you don't use ACM) , route depending on your host name, each hostname will route to one target group.在 ALB 的 443 端口上创建监听规则(如果不使用 ACM,则为 80),根据您的主机名进行路由,每个主机名将路由到一个目标组。

You can't do what you want in DNS using Route 53. See Can DNS point to specific port?您不能使用 Route 53 在 DNS 中做您想做的事情。请参阅Can DNS point to specific port? - Webmasters Stack Exchange There are several ways to implement what you want: - 网站管理员堆栈交换有几种方法可以实现您想要的:

Virtual hosts and reverse proxy虚拟主机和反向代理

It is very common to run Apache on Nginx on your server on ports 80/443 for HTTP/HTTPS respectively.在服务器上的 Nginx 上分别运行 HTTP/HTTPS 端口 80/443 上的 Apache 是很常见的。 Both support virtual hosts where you point multiple domain names to the same server and the forward the requests to other ports.两者都支持虚拟主机,您将多个域名指向同一服务器并将请求转发到其他端口。 See What is a "reverse proxy" in webmastering?请参阅什么是网站管理中的“反向代理”?

Multiple load balancers多个负载均衡器

You could create multiple Amazon ELBs that forward requests to different ports.您可以创建多个将请求转发到不同端口的 Amazon ELB。 Then Route 53 could point each domain to its own load balancer.然后 Route 53 可以将每个域指向其自己的负载均衡器。

Content delivery network (CDN)内容交付网络 (CDN)

Amazon's CDN is called Cloudfront .亚马逊的 CDN 称为Cloudfront It has sit between your site and your visitors and do the mapping that you want.它位于您的网站和访问者之间,并执行您想要的映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM