Reputation: 443
I am trying to setup a wordpress as part of my learning process.
I have installed wordpress and configured it on two aws instances with a single RDS. It seems to work fine.
Now I am adding a load balancer. How do I make the wordpress that I have installed in two different instances work together under a load balancer? I am not looking for a production level example and would prefer to do it in a simple way without autoscaling or Elastic beanstalk. TIA
Upvotes: 0
Views: 1594
Reputation: 193
Elastic Load Balancing supports three types of load balancers- Application Load Balancer, Network Load Balancer, Classic Load Balancer. In this case, you have to use Application Load Balancer.
Step 1: Select a Load Balancer Type
To create an Application Load Balancer
Step 2: Configure Your Load Balancer and Listener
On the Configure Load Balancer page, complete the following procedure.
To configure your load balancer and listener
For Name, type a name for your load balancer.
The name of your Application Load Balancer must be unique within your set of Application Load Balancers and Network Load Balancers for the region, can have a maximum of 32 characters, can contain only alphanumeric characters and hyphens, must not begin or end with a hyphen, and must not begin with "internal-".
For Scheme and IP address type, keep the default values.
For Listeners, keep the default, which is a listener that accepts HTTP traffic on port 80.
For Availability Zones, select the VPC that you used for your EC2 instances. For each Availability Zone that you used to launch your EC2 instances, select the Availability Zone and then select the public subnet for that Availability Zone.
Choose Next: Configure Security Settings.
Step 3: Configure a Security Group for Your Load Balancer
The security group for your load balancer must allow it to communicate with registered targets on both the listener port and the health check port. The console can create security groups for your load balancer on your behalf, with rules that specify the correct protocols and ports.
Note
If you prefer, you can create and select your own security group instead. For more information, see Recommended Rules.
On the Configure Security Groups page, complete the following procedure to have Elastic Load Balancing create a security group for your load balancer on your behalf.
To configure a security group for your load balancer
Step 4: Configure Your Target Group
Create a target group, which is used in request routing. The default rule for your listener routes requests to the registered targets in this target group. The load balancer checks the health of targets in this target group using the health check settings defined for the target group. On the Configure Routing page, complete the following procedure.
To configure your target group
Step 5: Register Targets with Your Target Group On the Register Targets page, complete the following procedure.
To register targets with the target group
For Instances, select one or more instances in your case you should select your two instances.
Keep the default port, 80, and choose Add to registered.
When you have finished selecting instances, choose Next: Review.
Step 6: Create and Test Your Load Balancer Before creating the load balancer, review the settings that you selected. After creating the load balancer, verify that it's sending traffic to your EC2 instances.
To create and test your load balancer
On the Review page, choose Create.
After you are notified that your load balancer was created successfully, choose Close.
On the navigation pane, under LOAD BALANCING, choose Target Groups.
Select the newly created target group.
On the Targets tab, verify that your instances are ready. If the status of an instance is initial, it's probably because the instance is still in the process of being registered, or it has not passed the minimum number of health checks to be considered healthy. After the status of at least one instance is healthy, you can test your load balancer.
On the navigation pane, under LOAD BALANCING, choose Load Balancers.
Select the newly created load balancer.
On the Description tab, copy the DNS name of the load balancer (for example, my-load-balancer-1234567890.us-west-2.elb.amazonaws.com). Paste the DNS name into the address field of an Internet-connected web browser. If everything is working, the browser displays the default page of your server.
Upvotes: 2