Search code examples
amazon-web-servicesamazon-ec2amazon-elastic-beanstalkamazon-ecsaws-application-load-balancer

what tools should I use on AWS to map a port


I have a jfrog factory(port 8081) and jfrog docker( port 8082) running on an EC2 instance

with route53 I defined the url of the domain xxx.io and also two subdomains jrog.xxx.io and docker.xxx.io

with certificate manager I applied for a SSL certificate for the domain xxx.io who normaly is available as well for the subdomain if i dont make any mistakes .

What tools do I need to set up so that when a user enters the url jfrog.xxx.io it is redirected to the jfrog instance (port 8081) but the port of this instance must be mapped to 443 ?


Solution

  • You can use an application load balancer to achieve it.

    The load balancer works with target groups and you will need 2 target groups for your load balancer. First target group will map the https (443) to your jfrog docker and the second target group will map https (443) to your jfrog factory.

    The target group for jfrog factory will look like: enter image description here

    The target group for jfrog docker will look like below. P.S: My instance is unhealthy because it has nothing in it, just a dummy instance. enter image description here

    Important things in the target group is the port mapping of your application and the target type. Then register your EC2 instance with the target groups.

    Now in your load balancer, choose the tab Listeners and View/Edit rules for the listener of type HTTPS (443).

    Then add new rules using a condition host header which will then redirect traffic to your target groups based on your subdomains (host header), it should look something like below. P.S I do not have SSL certificates, so I have used http itself, https should not be any different. enter image description here

    The finally you must make a DNS entry of type CNAME to map your domain (xxx.io) to the load balancer's DNS name.

    This is where you will get the load balancer's DNS name: enter image description here