Unable to contact my service in an AWS EC2 instance - amazon-web-services

I just set up an EC2 instance along with a load balancer and a Route 53 domain. The domain is getactiveapi.com. I set up the load balancer to forward port 80 and 443 to 8080. I have a simple spring boot application running on port 8080. One of my spring boot endpoints is /test. I am trying to hit that endpoint with getactiveapi.com/test with no luck. Am I doing something wrong here?

You should debug this by breaking down the individual components.
The flow is:
Domain name
Load Balancer
EC2 instance (also, the Security Group acts like a layer)
Start by getting the IP address of the Amazon EC2 instance and try connecting to it from your web browser. If it works, then the problem lies in a higher layer.
If the application instance is in a private subnet, then first login to another instance in a public subnet of the same VPC, then try connecting to the application instance.
If the application instance is not responding correctly, try logging into the application instance and run curl localhost:8080. If this works, then the problem probably lies with the Security Group settings. If it does not work, then your application is not running.
To test the Load Balancer, get the DNS Name of the load balancer and try accessing it. If this works, then the problem lies with Route 53. If it does not work, then the problem lies with the load balancer configuration.
Keep moving through the layers (bottom-up) until you discover what is causing the issue.

Related

AWS Load Balancer DNS is working but it doesn't pass the health check

I have a the application load balancer set up with a security group. I also have my ec2 instance (windows) set up with another security group. My ec2 instance is configured in vpc.
If I type the load balancer dns (for example http://alb-myrpoject-437610392.us-east-2.elb.amazonaws.com/) on the browser it works but the health check fails. Here is the screenshot of the target group:
I am using the Apache web server.
Any idea why the health check is failing while the load balancer dns works?
Thanks for trying to help with your comments. I realized that I didn't give enough info. Okay, I've finally figured it out. On the security group of the ec2 instance, I also added
HTTP TCP 80 0.0.0.0/0
Now the health check became healthy I can also reach out my web page using my ip of my ec2 instance.

Route53 - DNS resolution to a specific port on an EC2 instance

I have a website that I have hosted on an EC2 instance that runs on port 3000. (e.g. 3.27.83.19:3000 - assuming the IP address of the EC2 instance is 3.27.83.19)
I have a domain that I have already bought mydomain.com through AWS that I already see in Hosted Zones.
How can I set-up Route53 so that when someone hits "mydomain.com", it takes them to 3.27.83.19:3000 rather than 3.27.83.19
Thanks!
point domain to instance ip
To point example.com to 3.27.83.19 you simply need to create an A record in route53
point domain to load balancer
To access the website running port 3000 on an EC2 instance through https://example.com, you need a service that accepts traffic on https://example.com and then forward the traffic to the EC2 instance on port 3000. You can easily do it with an AWS application load balancer. I like this approach.
There are many benefits using an application load balancer. The important one is that you can configure the SSL certificate easily. The application load balancer also supports host based routing which allows you to host multiple websites.
If you are looking for less expensive solutions, you can also go for setting up an nginx proxy inside the ec2 instance. I personally don't like this approach because you will need to configure SSL at the application level.
https://aws.amazon.com/premiumsupport/knowledge-center/public-load-balancer-private-ec2/
Hope this helps.

unable to make Elastic Load Balancer work on port 8080

My EC2 instance has a site hosted using tomcat and that can be accessed using
http://public-Ip:8080/index.html
But when i put this instance behind a elastic load balancer, set the health check to
HTTP:8080/index.html
though the ELB passes the health check, when i try to access the using site using
http://ELB:8080/index.html
i am unable to access the site.
Is there something that is missing? or i need to do additionally.
This is how my LB listner tab looks like
LB listner tab
There was issue with the communication between the Security Group (SG) of my EC2 instances and the Elactic Load balancer(ELB) SG. I allowed my EC2 SG in the ELB SG and that helped.

Elastic load balancer - EC2s InService, but can't connect

Just getting an Elastic Load Balancer up for my application servers, and I'm having trouble connecting.
I placed 2 EC2 instances behind the load balancer, and both of them are successfully connected and InService, but putting the URL of the load balancer into Chrome never receives a response - it just hangs forever.
The ELB is placed under the security group where all incoming/outgoing is allowed.
Amazon's documentation assumes that something is wrong with your application servers, but they both work great, and the health checks are passing.
Help?
EDIT: Not using CNAME, guys. This is for a backend service, so I'm using the bare public DNS provided by AWS automatically. It's like:
http://api-load-balancer-XXXXXXXXX.us-west-1.elb.amazonaws.com/
And no, EC2 instances are also available to the internet gateway with a public url - One of these instances is currently being used for serving the application publicly, and it's working just fine for that. Just want some redundancy in case of failure, so I spun up another one.
Listeners is configured to only HTTP (port 80 on ELB, port 80 on instances).
I am pretty sure you just have to wait for 15-30 minutes before you will finally be able to resolve load balancer's IP address by DNS name. It happened to me when I was doing AWS tutorials.

aws - how to access opsWorks app with ELB?

My app was easy deployed on 3 instances using OpsWorks. I can Access it using instance IP's fine.
My question is: how can I access it using load balancer?
ELB says all 3 instances are InService, but typing public DNS on browser, it loads forever and shows nothing.
Testing ELB public DNS on http://whatsmydns.com it shows IP's that aren't from my instances.
Am I doing something wrong?
I have added Public DNS to my app as hostname.
There are a couple things to check:
Check that your load balancer listeners are configured to listen
and pass traffic to the same port that the instance is listening on
(for example http traffic 80 => http 80, https traffic 443 => https
443)
Check that the security group of the webservers allows
traffic from the loadbalancer. Though if you can access your instances directly via browser, I'm guessing they are open to 0.0.0.0/0 so shouldn't be an issue here?
Check that security group of the load balancer allows access to public on all needed ports (typically 80 and 443)
Check that elb healthcheck is not failing (under elb
instances you can see if the instances are in service or not) If it
says "Out of service" that's the problem. You need to make sure that
healthcheck URL is accessible and returns 200.
The DNS of your load balancer is different from your instances - it returns the IP addresses of the instances that the load balancer is running on, AWS usually has at least 3 servers behind the scenes for that.