You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inet 192.168.1.141/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
68
68
```
69
+
!!! Note
70
+
In this case, the interface we are looking for is "eno1" but this could be completely different on your system. Use **your** interface information!
69
71
70
-
In this case, the interface we are looking for is "eno1" but this could be completely different on your system. Use **your** interface information! Now that we know the LAN interface, we can modify our `macvlan` profile. To do this, at the command line type:
72
+
Now that we know the LAN interface, we can modify our `macvlan` profile. To do this, at the command line type:
71
73
72
74
`lxc profile edit macvlan`
73
75
@@ -162,7 +164,7 @@ and then do a search for the `<h1>` tag, which should show this:
162
164
163
165
Simply change that line to read:
164
166
165
-
`<h1>WEB1 HTTP Server <strong>Test Page</strong></h1>`
167
+
`<h1>SITE1 HTTP Server <strong>Test Page</strong></h1>`
166
168
167
169
Now repeat the process for web2. Going to these machines by IP in a browser should now return the correct welcome page for each. There's more to do on the web servers, but let's leave them and go on to the proxy server next.
For our testing, we are probably only going to use port 80, or HTTP traffic, but this shows you how you would configure the container to listen on the default web ports for both HTTP and HTTPS. Using this command also ensures that restarting the **proxyha** container will maintain those listening ports.
183
+
For our testing, we are only going to use port 80, or HTTP traffic, but this shows you how you would configure the container to listen on the default web ports for both HTTP and HTTPS. Using this command also ensures that restarting the **proxyha** container will maintain those listening ports.
182
184
183
185
## The HAProxy Configuration
184
186
185
-
We've already installed HAProxy on the container, but we have done nothing with the configuration. Before we do anything, we need to do something to resolve our hosts. Normally we would be using fully-qualified domain names, but in this lab environment, we are just using IPs. To get some names associated with the machines, we are going to add some hosts file records to the **proxyha** container.
187
+
We've already installed HAProxy on the container, but we have done nothing with the configuration. Before we do anything, we need to do something to resolve our hosts. Normally we would be using fully-qualified domain names, but in this lab environment, we are just using IPs. To get some names associated with the machines, we are going to add some host file records to the **proxyha** container.
186
188
187
189
`lxc exec proxyha vi /etc/hosts`
188
190
189
191
Add the following records to the bottom of the file:
190
192
191
193
```
192
-
192.168.1.150 web1.testdomain.com web1
193
-
192.168.1.101 web2.testdomain.com web2
194
+
192.168.1.150 site1.testdomain.com site1
195
+
192.168.1.101 site2.testdomain.com site2
194
196
```
195
197
196
198
Which should allow the **proxyha** container to resolve those names.
A little explanation of what's going on above. You should see this in your testing, when you get to the testing section of this guide (below):
281
283
282
-
Both **web1** and **web2** are definded in the "acl" section. Then both **web1** and **web2** are included in each other's "roundrobin" for their respective back ends. What happens when you go to web1.testdomain.com in the test, the URL does not change, but the page inside will switch each time you access the page from the web1 to the web2 test pages. Same goes for web2.testdomain.com.
284
+
Both **site1** and **site2** are defined in the "acl" section. Then both **site1** and **site2** are included in each other's "roundrobin" for their respective back ends. What happens when you go to site1.testdomain.com in the test, the URL does not change, but the page inside will switch each time you access the page from the **site1** to the **site2** test pages. Same goes for site2.testdomain.com.
283
285
284
286
This is done to show you the switch is occurring, but in reality, your website content will look exactly the same regardless of which server you are hitting. Keep in mind that we are showing how you might want to distribute traffic between multiple hosts. You can also use "leastcon" in the balance line, and instead of switching based on the previous hit, it will load the site with the least number of connections.
285
287
@@ -403,7 +405,7 @@ If everything starts and runs without issue, we are ready to move on to testing.
403
405
404
406
## Testing The Proxy
405
407
406
-
As with the hosts (`/etc/hosts`) setup that we used so that our **proxyha** container can resolve the web servers, and since in our lab environment we don't have a local DNS server running, we need to set the hostname values on our local machine for both the **web1** and **web2** containers. But, instead of using their IP addresses, we need to use the **proxyha** IP address for both.
408
+
As with the hosts (`/etc/hosts`) setup that we used so that our **proxyha** container can resolve the web servers, and since in our lab environment we don't have a local DNS server running, we need to set the IP values on our local machine for both the site1 and site2 websites, to correspond to our haproxy container.
407
409
408
410
To do this, we need to modify our `/etc/hosts` file on our local machine. Consider this method of domain resolution a "poor man's DNS."
409
411
@@ -412,19 +414,20 @@ To do this, we need to modify our `/etc/hosts` file on our local machine. Consid
412
414
Then just add these two lines:
413
415
414
416
```
415
-
192.168.1.149 web1.testdomain.com web1
416
-
192.168.1.149 web2.testdomain.com web2
417
+
192.168.1.149 site1.testdomain.com site1
418
+
192.168.1.149 site2.testdomain.com site2
417
419
```
418
420
419
-
If you ping either **web1** or **web2** on your local machine now, you should get a response from **proxyha**:
421
+
If you ping either **site1** or **site2** on your local machine now, you should get a response from **proxyha**:
420
422
421
423
```
422
-
PING web1.testdomain.com (192.168.1.149) 56(84) bytes of data.
423
-
64 bytes from web1.testdomain.com (192.168.1.149): icmp_seq=1 ttl=64 time=0.427 ms
424
-
64 bytes from web1.testdomain.com (192.168.1.149): icmp_seq=2 ttl=64 time=0.430 ms
424
+
PING site1.testdomain.com (192.168.1.149) 56(84) bytes of data.
425
+
64 bytes from site1.testdomain.com (192.168.1.149): icmp_seq=1 ttl=64 time=0.427 ms
426
+
64 bytes from site1.testdomain.com (192.168.1.149): icmp_seq=2 ttl=64 time=0.430 ms
425
427
```
426
428
427
-
Now open your web browser and type web1.testdomain.com (or web2.testdomain.com) as the URL in the address bar. You should get a response back from one of the two test pages and if you load the page again, you should get the next server's test page. Note that the URL does not change, but the returned page will change alternately between servers.
429
+
Now open your web browser and type site1.testdomain.com (or site2.testdomain.com) as the URL in the address bar. You should get a response back from one of the two test pages and if you load the page again, you should get the next server's test page. Note that the URL does not change, but the returned page will change alternately between servers.
430
+
428
431
429
432

0 commit comments