Question:
I have a web app which runs behind Amazon AWS Elastic Load Balancer with 3 instances attached. The app has a /refresh
endpoint to reload reference data. It need to be run whenever new data is available, which happens several times a week.
What I have been doing is assigning public address to all instances, and do refresh independently (using ec2-url/refresh
). I agree with Michael’s answer on a different topic, EC2 instances behind ELB shouldn’t allow direct public access. Now my problem is how can I make elb-url/refresh
call reaching all instances behind the load balancer?
And it would be nice if I can collect HTTP responses from multiple instances. But I don’t mind doing the refresh blindly for now.
Answer:
You can’t make these requests through the load balancer, So you will have to open up the security group of the instances to allow incoming traffic from source other than the ELB. That doesn’t mean you need to open it to all direct traffic though. You could simply whitelist an IP address in the security group to allow requests from your specific computer.
If you don’t want to add public IP addresses to these servers then you will need to run something like a curl
command on an EC2 instance inside the VPC. In that case you would only need to open the security group to allow traffic from some server (or group of servers) that exist in the VPC.