|
1 | 1 | --- |
2 | 2 | meta: |
3 | 3 | title: Setting up a load-balanced WordPress |
4 | | - description: This page shows you how to set up a load-balanced WordPress for increased availability |
| 4 | + description: Set up a Scaleway Load Balancer for WordPress to improve performance, ensure high availability, and handle traffic efficiently. |
5 | 5 | content: |
6 | 6 | h1: Setting up a load-balanced WordPress |
7 | | - paragraph: This page shows you how to set up a load-balanced WordPress for increased availability |
| 7 | + paragraph: Set up a Scaleway Load Balancer for WordPress to improve performance, ensure high availability, and handle traffic efficiently. |
8 | 8 | categories: |
9 | 9 | - load-balancer |
10 | 10 | - instances |
11 | 11 | tags: WordPress Load-Balancer |
12 | 12 | dates: |
13 | | - validation: 2024-11-18 |
| 13 | + validation: 2025-05-27 |
14 | 14 | posted: 2019-04-08 |
15 | 15 | --- |
16 | 16 |
|
@@ -45,111 +45,19 @@ Load Balancer supports private IPs of Scaleway Instances for backend servers, al |
45 | 45 |
|
46 | 46 | ## Configuring a Load Balancer |
47 | 47 |
|
48 | | -1. Click **Load Balancer** in the menu on the left, to enter the Load Balancer section, then click **+ Create a Load Balancer**: |
49 | | - <Lightbox src="scaleway-lb-console.webp" alt="" /> |
50 | | -2. Enter the **Name** of the Load Balancer, optionally you can enter a description and tags to simplify the management of them. Choose the **Region** for the Load Balancer (it should be the same region as the geographical region of your Instances), and a new IP address is allocated automatically.1. Click **Load Balancer** in the menu on the left, to enter the Load Balancer section, then click **+ Create a Load Balancer**: |
51 | | - <Lightbox src="scaleway-lb-console.webp" alt="" /> |
52 | | -3. Enter the **Name** of the Load Balancer, optionally you can enter a description and tags to simplify the management of them. Choose the **region** for the Load Balancer (it should be the same region as the geographical region of your Instances), and a new IP address is allocated automatically. |
53 | | -4. Configure a backend rule, this rule defines the backend infrastructure that will be load-balanced. |
| 48 | +1. Follow the instructions for [creating a Load Balancer](/load-balancer/how-to/create-load-balancer/#how-to-create-a-load-balancer), with the following settings: |
| 49 | + - The same Availability Zone as your Instances |
| 50 | + - A frontend listening on port 80 |
| 51 | + - A backend using HTTP protocol, listening on port 80 |
| 52 | + <Message type="tip"> |
| 53 | + It is also possible to use [SSL to encrypt backend connections](/tutorials/nginx-reverse-proxy/), in this case, set the port to 443.| |
| 54 | + </Message> |
| 55 | + - TLS encryption activated on the backend |
| 56 | + - Proxy protocol deactivated on the backend |
| 57 | + - The two WordPress Instances (`10.45.2.3` and `10.45.2.3`) as backend server IPs |
| 58 | + - HTTP health check |
54 | 59 |
|
55 | | - The following parameters should be configured in the backend rule: |
56 | | - |
57 | | - |Parameter|Description| |
58 | | - |----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| |
59 | | - |**Backend Name**|A name for the backend rule (e.g. `wordpress-backend-rule`)| |
60 | | - |**Protocol**|The protocol to use. Set this value to `HTTP`, to have access to HTTP-specific features of the Load Balancer| |
61 | | - |**Port**|The port on which the backend application listens, with a standard configuration is **port 80** for a web application. It is also possible to use [SSL to encrypt backend connections](/tutorials/nginx-reverse-proxy/), in this case, set the port to 443.| |
62 | | - |**Proxy**|This enables or disables PROXY protocol version 2 (must be supported by backend servers). It is not required for this tutorial, keep it off.| |
63 | | - |**TLS encryption**|Enable Transport Layer Security (TLS) to encrypt connections between the Load Balancer and the backend server(s).| |
64 | | - |**Health Check Type**|The health check type to use. To check the health of a web application, set this to `HTTP`.| |
65 | | - |**Server IPs**|Add the two WordPress Instances (`10.45.2.3` and `10.45.2.3`) to the list of backend servers| |
66 | | - |
67 | | - The final backend rule should look similar to the following example: |
68 | | - |
69 | | - <Lightbox src="scaleway-lb-backend-rule.webp" alt="" /> |
70 | | -5. Click **Create a Load Balancer** to deploy the Load Balancer. |
71 | | - |
72 | | -## Checking if the Load Balancer works |
73 | | - |
74 | | -It is possible to check the status of the Load Balancer with an API call. |
75 | | -It will provide you with information about the status of the Load Balancer and if the health check was successful. |
76 | | - |
77 | | -<Message type="important"> |
78 | | - Retrieve your Organization ID and generate [API key](/iam/how-to/create-api-keys/) from your [management console](https://console.scaleway.com/project/credentials) before you continue. |
79 | | -</Message> |
80 | | - |
81 | | -1. Set the required variables to make the API call easier: |
82 | | - ```bash |
83 | | - LB_ID="<LOAD_BALANCER_ID>" |
84 | | - TOKEN="<API_SECRET_KEY>" |
85 | | - REGION="<REGION>" # (can be either fr-par or nl-ams, depending on the load balancers region) |
86 | | - ``` |
87 | | -2. When the Load Balancer is configured and running, type the following command to request its status. Make sure that [jsonpp](https://jmhodges.github.io/jsonpp/) is installed on the machine running the above command to get an easily readable JSON output: |
88 | | - ```bash |
89 | | - curl -X GET "https://api.scaleway.com/lb/v1/regions/$REGION/lbs/$LB_ID/stats" -H "X-Auth-Token: $SECRET_KEY" | json_pp |
90 | | - ``` |
91 | | -3. The API will provide a [JSON formatted](https://en.wikipedia.org/wiki/JSON) response like the following example: |
92 | | - ```json |
93 | | - { |
94 | | - "backend_servers_stats": [ |
95 | | - { |
96 | | - "ip": "10.45.2.3", |
97 | | - "backend_id": "cd64b4e0-2c23-484a-80b9-602bf934245e", |
98 | | - "instance_id": "4d2294bf-4e6d-499c-922a-ca08f58ed66d", |
99 | | - "server_state_changed_at": "2019-04-10T13:01:27Z", |
100 | | - "server_state": "stopped", |
101 | | - "last_health_check_status": "failed" |
102 | | - }, |
103 | | - { |
104 | | - "server_state": "stopped", |
105 | | - "server_state_changed_at": "2019-04-10T13:01:27Z", |
106 | | - "instance_id": "4d2294bf-4e6d-499c-922a-ca08f58ed66d", |
107 | | - "ip": "10.45.2.4", |
108 | | - "backend_id": "cd64b4e0-2c23-484a-80b9-602bf934245e", |
109 | | - "last_health_check_status": "unknown" |
110 | | - }, |
111 | | - { |
112 | | - "instance_id": "bd4b6e5f-2cfb-40da-afd8-933e7afbbd61", |
113 | | - "server_state_changed_at": "2019-04-10T13:01:27Z", |
114 | | - "server_state": "running", |
115 | | - "backend_id": "cd64b4e0-2c23-484a-80b9-602bf934245e", |
116 | | - "ip": "10.45.2.3", |
117 | | - "last_health_check_status": "passed" |
118 | | - }, |
119 | | - { |
120 | | - "ip": "10.45.2.4", |
121 | | - "backend_id": "cd64b4e0-2c23-484a-80b9-602bf934245e", |
122 | | - "instance_id": "bd4b6e5f-2cfb-40da-afd8-933e7afbbd61", |
123 | | - "server_state_changed_at": "2019-04-10T13:01:27Z", |
124 | | - "server_state": "running", |
125 | | - "last_health_check_status": "passed" |
126 | | - } |
127 | | - ] |
128 | | - } |
129 | | - ``` |
130 | | - |
131 | | - As two Instances are configured in the backend, the JSON list contains four entries. This is due to the high availability feature of the Load Balancer. Should the master Instance experience a failure, it switches automatically to the backup one. |
132 | | - |
133 | | - In the status of the `running` instance, the health check status (`last_health_check_status`) has `passed`. This means that the backend Instance replied well to the request sent to it in the health check. Requests to WordPress are load-balanced between the two Instances. |
134 | | -4. Connect to the first WordPress Instance (`10.45.2.3`) and stop the web server application running on it: |
135 | | - ```bash |
136 | | - systemctl stop nginx.service |
137 | | - ``` |
138 | | -5. Re-run the command from Step 3. |
139 | | -6. In the JSON list, the `last_health_check_status` changed to `failed`, as the web server no longer replies to requests: |
140 | | - ```json |
141 | | - { |
142 | | - "last_health_check_status": "failed", |
143 | | - "server_state": "stopped", |
144 | | - "instance_id": "bd4b6e5f-2cfb-40da-afd8-933e7afbbd61", |
145 | | - "ip": "10.45.2.3", |
146 | | - "server_state_changed_at": "2019-04-10T13:32:18Z", |
147 | | - "backend_id": "cd64b4e0-2c23-484a-80b9-602bf934245e" |
148 | | - } |
149 | | - ``` |
150 | | - |
151 | | - When you navigate to the load-balanced IP (`http://51.51.51.51`) in your browser, your WordPress displays. The Load Balancer has automatically detected that the Nginx server on the first Instance (`10.45.2.3`) is not running anymore and redirects all traffic to the second Instance (`10.45.2.3`). |
152 | | -7. Restart the web server application and re-run the command mentioned in step 3. The `last_health_check_status` will change again into `passed` and requests are load balanced again between the two Instances. |
| 60 | +2. Check the status of your Load Balancer's backend servers in the Scaleway console, by navigating to the Load Balancer's dashboard, then **Backends** > **Backend name** > **Server list**, where you can see the status of each server depending on its health check result. |
153 | 61 |
|
154 | 62 | ## Configuring WordPress |
155 | 63 |
|
@@ -183,11 +91,11 @@ Update the configuration of each Instance now, so they will use the database on |
183 | 91 | When connecting to the Instance from a web browser, the content is taken from the database on the MariaDB server. |
184 | 92 | 3. Log into the WordPress Admin interface and click **Settings** to configure WordPress. |
185 | 93 | - Enter the IP of one of your WordPress Instances (`10.45.2.3`) in the field **WordPress Address (URL)** |
186 | | - - Enter the **Load Balanced IP** (`51.51.51.51`) or your domain name in the field **Site Address (URL)** |
| 94 | + - Enter the **Load Balancer's public (flexible) IP address** (`51.51.51.51`) or your domain name in the field **Site Address (URL)** |
187 | 95 |
|
188 | 96 | Save the form. |
189 | 97 | 4. Redo this step on the second instance. |
190 | | -5. Type the **Load Balanced IP** or your domain name in your browser, and WordPress will appear on the load balanced IP: |
| 98 | +5. Type the **Load Balancer's public (flexible) IP address** or your domain name in your browser, and WordPress will appear : |
191 | 99 | <Lightbox src="scaleway-lb-wp-lbip.webp" alt="" /> |
192 | 100 |
|
193 | | -The Load Balancer is now automatically distributing the load between your Instances. To increase the computing power of the Load Balancer, simply snapshot an Instance and spin up a new one. |
| 101 | +The Load Balancer is now automatically distributing the load between your Instances. To increase the computing power of the Load Balancer, simply [snapshot](/instances/concepts/#snapshot) an Instance and spin up a new one. |
0 commit comments