-1

I have an application which can be reached by typing http://EC2 IP:3838/My_app. But I need a domain name rather than this address and so purchased a DNS from AWS and linked it to the EC2 IP. now I can get access to the app by my-dns-name:3838/My_app but it is unusual to have 3838/My_app at the end of the domain name. I was directed "f you want to people to access your application by only using a domain name, you'll need to either change the port for your app, or run a web server on port 80/443 that can redirect users". Can anybody help me on that?

This is what I've done so far: For deploying my Shiny application, I created an EC2 IP in AWS and then installed shiny server and Rstudio so that I could deploy my app. So now I have an IP with the following linkage (I’m using MyIP instead of the IP number):

MyIP:3838 opens shiny server MyIP:8787 opens Rstudio MyIP:3838/My_app opens my application Then I created a hosted zone from route 53 and linked my EC2 IP to my domain name.

Thank you

2
  • 1
  • 1
    There are thousands, if not millions of examples of how to do this already on the internet all you need to do is search for them. There will likely be hundreds if not thousands of examples of this within stack exchange, all you need to do is search for them.
    – user9517
    Feb 10, 2019 at 22:14

1 Answer 1

0

First off, it looks like you have chosen a wrong hosting platform. AWS EC2 is too powerful and flexible for the task you are trying to solve. If your task is limited to hosting a simple web application, then you should use something simpler, like webhosting from Hetzner, which has everything included for a pretty small price.

If you still want to stick with AWS, you have options: use AWS services or do everything yourself. If you want to do it AWS way, then you should create a Load Balancer in front of your application. AWS will take care of everything: port redirection and SSL certificate, needed for port 443. However, to be honest, a Load Balancer is a bit of an overkill for a single EC2 instance configuration. Also, this would cost you additional money, as Load Balancers are not free (SSL certificates are, though).

If you do not want to pay for a Load Balancer, then you need to follow the advices given to you in the comments - which means you will have to set up a HTTP proxy and an SSL certificate for it (I suggest Letsencrypt). If you are willing to pay, then you need to do the following:

  1. Go to Amazon Certificate Manager and request a new certificate for the domain you created (the one you replaced with my-dns-name). As you start doing it, AWS will give you exhaustive instructions on how to verify your domain.
  2. Go to EC2 -> Load Balancers and create a Classic Load Balancer. Create two listeners to it: one for HTTP from port 80 to 3838, and one for HTTPS from port 443 to 3838. Attach the SSL certificate you obtainer earlier, to the second listener.
  3. Attach your EC2 instance to the Load Balancer you created.
  4. Go to Route53, remove the record that points to your EC2 instance, and replace it with a CNAME record pointing to the Load Balancer's DNS name. Alternatively, you can create an A record instead, make it an Alias and point it to the Load Balancer (this is even more AWS way).

If you've done everything correctly, then your site should become available both by http://my-dns-name/My_app and https://my-dns-name/My_app.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .