AWS send http request through elastic load balancer - http

I am a beginner and trying to send http requests through elastic load balancer. Could anybody explain briefly about the steps that I need?
set up Elastic Load Balancer A
get DNS of the Elastic Load Balancer A
register EC2 instances to the Elastic Load Balancer A
send traffic to the DNS of Elastic Load Balancer A
But I have no idea what kind of configuration or set up I need to put in the EC2 instances that are to be attached to this Elastic Load Balancer A. Do I need to set up Listener? If so, how do I set this?
I just want to send http request under the ip of EC2s and Elastic Load Balancer A so that I get different IPs assigned to each requests.
Thanks a lot!

By default, Amazon EC2 instances behind an Elastic Load Balancer serve traffic on port 80 (HTTP). When creating the Load Balancer, you can configure which ports should receive traffic (80, 442, 1024+).
Think of it this way... The Load Balancer simply sits "in front" of the EC2 instances. If a user was to go directly to your EC2 instance directly (eg enter its IP Address in a web browser), they should see a website. Going to the Load Balancer does the same thing, but it distributes the requests amongst multiple EC2 instances.
So, in most cases, it's just a matter of running a web server or app on your EC2 instance running on port 80.

Related

GCP Kube-Lego forwarding rule pricing

I've started to use kube-lego to manage load-balancing through a nginx controller, instead of GCP Load Balancer controller.
I am being charged for: Network Load Balancing: Forwarding Rule Minimum Service Charge in EMEA right now, at about 21$ per month.
Isn't the load balancing supposed to be done by nginx?
I have TCP Load Balancer in my GCP network resources.
Isn't possible to send the traffic to a node port and do the load balancing on the nginx controller instead ?
I thought the advantage of having a Nginx load balancer would avoid creating a load balancer on GCP and thus avoiding paying crazy expansive network resources.
What is the purpose of the nginx controller then? Beside maybe automatic certificate renewal with LE.

Can AWS Load Balancer be configured to filter out requests?

I have a Django app deployed on AWS Elastic Beanstalk. Django is configured to only serve requests that comes for a specific hostname (ALLOWED_HOSTS). If the host information in the request doesn't match, it will raise return 500 response code, that is fine.
But, I have noticed that I get quite many of those, either sending requests vis IP address, or via other domain names. So, I would like to configure the setup so that the load balancer rejects the request if it doesn't have the proper hostname in the header information.
Is this possible to do? I have been trying to go over settings in the AWS Console, but cannot find any information how to do this. I could patch the EC2 instances to reject those request so it doesn't reach Django at all, but I would like to stop it as early as possible.
Flow now:
Client -> Load Balancer -> EC2 instance -> Nginx -> Django
<-500 error- Django
What I want:
Client -> Load Balancer
<-reject- Load Balancer
Elastic Load Balancer cannot be configured to filter out requests.
If your allowed connections are based on IP address, then you can use VPC ACLs to allow only connections from certain IP addresses. All others will receive failed connections at the ELB level.
If your allowed connections are not based on IP address you can take a look at CloudFront in combination with Amazon Web Application Firewall (WAF).
WAF can be configured to filter at the web request level by IP address, URL, query string, headers, etc.

Google cloud HTTP load balancer always returns unhealthy instance for meteor app

I am trying to set up a HTTP load balancer for my Meteor app on google cloud. I have the application set up correctly, and I know this because I can visit the IP given in the Network Load Balancer.
However, when I try and set up a HTTP load balancer, the health checks always say that the instances are unhealthy (even though I know they are not). I tried including a route in my application that returns a status 200, and pointing the health check towards that route.
Here is exactly what I did, step by step:
Create new instance template/group for the app.
Upload image to google cloud.
Create replication controller and service for the app.
The network load balancer was created automatically. Additionally, there were two firewall rules allowing HTTP/HTTPS traffic on all IPs.
Then I try and create the HTTP load balancer. I create a backend service in the load balancer with all the VMs corresponding to the meteor app. Then I create a new global forwarding rule. No matter what, the instances are labelled "unhealthy" and the IP from the global forwarding rule returns a "Server Error".
In order to use HTTP load balancing on Google Cloud with Kubernetes, you have to take a slightly different approach than for network load balancing, due to the current lack of built-in support for HTTP balancing.
I suspect you created your service in step 3 with type: LoadBalancer. This won't work properly because of how the LoadBalancer type is implemented, which causes the service to be available only on the network forwarding rule's IP address, rather than on each host's IP address.
What will work, however, is using type: NodePort, which will cause the service to be reachable on the automatically-chosen node port on each host's external IP address. This plays more nicely with the HTTP load balancer. You can then pass this node port to the HTTP load balancer that you create. Once you open up a firewall on the node port, you should be good to go!
If you want more concrete steps, a walkthrough of how to use HTTP load balancers with Container Engine was actually recently added to GKE's documentation. The same steps should work with normal Kubernetes.
As a final note, now that version 1.0 is out the door, the team is getting back to adding some missing features, including native support for L7 load balancing. We hope to make it much easier for you soon!

Clarification of nginx and load balancing needed

I'm now reading design of Instagram and I found such a description of their load balancing system.
Every request to Instagram servers goes through load balancing machines; we used to run 2 nginx machines and DNS Round-Robin between them. The downside of this approach is the time it takes for DNS to update in case one of the machines needs to get decomissioned. Recently, we moved to using Amazon’s Elastic Load Balancer, with 3 NGINX instances behind it that can be swapped in and out (and are automatically taken out of rotation if they fail a health check). We also terminate our SSL at the ELB level, which lessens the CPU load on nginx. We use Amazon’s Route53 for DNS, which they’ve recently added a pretty good GUI tool for in the AWS console.
The question is. Am I right that for now they have a DNS Server which uses RR to decide on which nginx server to send the request. And each of this nginx servers at their turn resends the request to a cluster?
And the second question is. What the difference between nginx and load balancer. Why cannot we use nginx instead?
For your first question, I believe the answer seems to be that Instagram now uses Route53 to map DNS to an Elastic Load Balancer, which does two things: It routes traffic fairly evenly to three NGINX load balancers, and it provides SSL for all traffic. The NGINX servers then act as load balancers to content/application servers further down the stack. Using an ELB instead of round-robin DNS means they can add/remove/update instances attached to the ELB without ever having to worry about DNS updates or TTL.
As for the second question, you can use NGINX just as easily as HAproxy or other services to do load balancing. I am sure that part of the appeal to Instagram in choosing NGINX is its incredible speed and that it's asynchronous and "event-driven" instead of threaded like Apache2. When set up properly, that can mean less headaches under heavy loads.

Amazon Elastic Load Balancer with IIS

I have and ASP.NET MVC application hosted under IIS on a EC2 Instance.
I can access the application without any problems through the EC2 DNS once I set the proper binding in IIS
http - EC2 DNS - port 80
But if I add an Elastic Load Balancer and then I try to access that web application through the Load Balancer DNS the only way I can get it working is by adding an empty binding in IIS
"empty host name for http:80"
But this can't be ok.
If I don't add this the ELB sees my instance as unhealthy and when I access the ELB DNS I just get a HTTP 503 Service Unavailable.
The EC2 instance is in a Auto Scaling group.
I've tried modifying the security group of that instance from allowing all IPs for HTTP:80 to only allowing the Load Balancer Ip (amazon-elb/amazon-elb-sg)
Any ideas what I'm doing wrong?
Thanks
I am running several IIS servers behind ELB. Here are things that you need to ensure:
The ELB security group is allowed to accept port 80 traffic from anywhere (0.0.0.0/0)
The ELB security group is allowed to send outbound port 80 traffic to your EC2 instance where IIS is running. This point was valid for the ELBs that are set inside VPC. Hence please ignore this.
The EC2 security group of the EC2 instance where you have IIS running, should be allowed to accept port 80 traffic from the Load Balancer.
If this whole set-up is in VPC then there are few other things you need to check. so let us know if this is the case
No configuration changes on IIS are needed for sure.

Resources