Unable to access Java web application using domain name

0

Hi All,

I hope you're all doing well.

I’m reaching out for some guidance as I’m new to AWS and working on my first project. I’ve set up an EC2 Windows instance and deployed a Java web application on a Tomcat server running on port 8080. I’ve also mapped my domain from GoDaddy to this instance.

Here’s what’s happening:

When I ping my domain, it correctly resolves to my instance's public IP address.
I can access the Java web application both locally and publicly using the domain name along with the Tomcat port number and the application folder name (e.g., http://mydomain.com:8080/myapp/index.html).

However, I’m facing a challenge:

I want to access my application using just the domain name (e.g., http://mydomain.com) without needing to specify the Tomcat port number or the application directory.

To address this, I created a load balancer and a target group, and the health checks show that everything is good. Despite this, I am still encountering the error: “The site can’t be reached.”

Could someone please help me figure out how to configure things so that I can access my Java web application using only the domain name?

Any guidance or suggestions would be greatly appreciated!

Thank you in advance!

MS
asked 12 days ago49 views
2 Answers
0
  1. Configure Tomcat to Listen on Port 80: Edit Tomcat’s server.xml file to change the HTTP connector port from 8080 to 80.

    Restart Tomcat after making the changes.

  2. Use a Load Balancer (If Keeping Tomcat on Port 8080):

  3. Configure an AWS Application Load Balancer to listen on port 80.

    Forward requests from the load balancer to your EC2 instance on port 8080.

    Update DNS records in GoDaddy to point to the load balancer’s DNS name.

  4. Check Security Group Settings:

    Ensure the security group allows inbound traffic on port 80 (or port 8080 if using a load balancer).

  5. Verify Load Balancer Health Checks: Ensure that health checks are correctly configured for the load balancer, pointing to the right port and path.

profile pictureAWS
EXPERT
Deeksha
answered 12 days ago
0

Hi there,

When you type http://mydomain.com in the browser, it will by default try to connect to port 80 of the target server, that why you needed to specific port 8080 when your server listens to that port.

To connect without specifying the port, you can either

If ALB is used, you also need to point your DNS name to the ALB's DNS name with a CNAME record.

The above allows you to access http://mydomain.com/myapp/index.html

Next, if you want to access the index.html without specifying the path, you also need to override the default landing page, see - https://stackoverflow.com/questions/3976160/how-does-tomcat-find-the-home-page-of-my-web-app

answered 12 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions