Search code examples
amazon-ec2webserveramazon-route53

How do I route all traffic to my EC2's ip address to a specific port?


I have a basic web application running on a port in an EC2 instance. I have also created an A record in Route53 which points a domain name that I own towards the ip address of the EC2 instance.

When I directly access ip-address:port, it works fine, but because the a record does not point towards that specific port, the website cannot be accessed through the domain name.

How do I specify a port that all requests to that ip address should be routed to?


Solution

  • port is referenced by protocol you are using.
    if you use http you will connect to port 80. https uses 443, ftp 21, smtp 25 and there are many others (they are called default ports for service but they may use every other defined).
    You are probably running application, listening on some different port (but using protocol http) and that's why you can reach it by entering http://ip-address:port
    what you can do to reach it by entering only http://ip-address is to set it to listen on port 80 (you will need root privileges to do this) or set redirect from port 80 to your applications port (you can use pure port redirection using iptables or (better) reverse proxy software. It can be apache as mentioned in comment above, or nginx or haproxy or something else (you haven't specified operating system anyway - those are mainly for linux).

    Hope that helps