How to add health check request ip to load balancer security group? - amazon-web-services

I face an issue in AWS Elastic BeanStalk health checking. I deployed to my NodeJS application to AWS via elastic beanstalk. Then I give permission my elastic load balancer TCP 443 port accessible for only my domain that is routed by Cloudflare. Basically, My elastic load balancer is only accessible by Cloudflare,
Due to the fact that I use Cloudflare, AWS health checks can not be able to access to the endpoint of the load balancer. How can fix this issue? I don't want to open my load balancer TCP 443 port to all world people. I want to open TCP 443 port for the only Cloudflare and, at the same time, I want to use health check of AWS :)

If somebody reads this question in the future, I thought that the health-check is being executed, externally - accessing publicly. But I have just learned that it was not :)). It is being executed directly internally. There is no problem related to Cloudflare or the security group or any other thing!
If there is an error in your ELB regarding this, the problem is probably related to your codebase, not the security group or other configurations.

Related

Do I need to configure certs on nginx itself if nginx is inside ec2 instance on loadbalancer which can only be accessed using https?

I have the cert applied on the load balancer, and https works fine, but i am wondering if I need to add the certs to nginx itself, which seems overkill but i am not sure.
No, one of the benefit of using a Load Balancer is you can hide your EC2 from public internet, making it less open and more secured.
Therefore, it is normal practice to use HTTP between your EC2 and load balancers, since they are in the same AWS Region (a safe and trusted internal environment).
By doing this you will also increase performance, because the https network overhead is only executed once in the load balancer, not twice. Your EC2 will focus the CPU resources on running the application logic instead.
Load Balancer is also Highly Available and can be configured to work with CloudFront and WAF for security and anti-DDoS controls.
No, you don't have to do this. The reason is that your load balancer (LB) is going to termiante the https connection, decrypt it using a SSL certificate you've deployed on it, and then forward HTTP connection to your ec2 instance(s).
Therefore, typical connections for LB with HTTPS have the following form:
client ---(HTTPS)---->LB---(HTTP)--->EC2 instance
This configuration is suited for most use-cases as HTTP traffic is happening withing AWS private network, not over the internet.

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.

Where can I find my AWS Application Load Balancer IP?

I have setup an AWS Network Load Balancer no problem and I have a number of different services running on their assigned ports. This all works perfectly.
Then I was asked to host a number of different node apps on their own ports and are accessed via their own domains. After I realised I couldn't get this to work correctly on NLB I looked to Application Load Balancer and use Host-Based Routing rules.
app1.example.com
app2.example.com
What I did
I setup the application load balancer listener on https :443 and a Host-Based Routing rule that forwards app1.example.com traffic to a target group to watch 443 and send the traffic to the correct instance on port 3000. The security group is also setup to with port 3000 open.
So I thought.... all I had to do was add the load balancer IP to the subdomain A Records on the external domain registrar.... but I can't find the IP anywhere! I'm missing something fundamental here and AWS docs are killing me.
The above steps aren't too different from setting up a Network Load Balancer without the Host-Based Routing rules.
Could anyone point out where I can find the ALB IP or where am I'm going off track?
The Ip might change so better use an other option such as CNAME or A-record + Alias (the latter might save you some money, if I remember correctly).
(Route 53 setup)

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.