Tag Archives: virtual hosts

Fixed my load balancer and got my new site on line

I’ve fixed the problem with my load balancer. The hard disk was completely dead, so I couldn’t execute any terminal commands. I just pulled the
plug and took out the hard disk. I replaced it with a hard disk from an old NAS, and reinstalled Lubuntu. I’m using Lubuntu because this PC
only has 512MB of RAM, so I need to save memory.

I installed Apache and set up mod proxy as described in this article about how I built my Raspberry Pi cluster.

While I was rebuilding the load balancer, my Raspberry Pi site was being hosted on a single Pi. Response times did suffer, but at least my site
wasn’t down completely.

This time when I set up Apache on the load balancer, I added the ServerName directive to the first virtual host:

<VirtualHost *:80>
 ServerName raspberrywebserver.com
...

 ProxyRequests Off
 <Proxy balancer://rpicluster>

 BalancerMember http://192.168.1.11:80 
 BalancerMember http://192.168.1.12:80 
 BalancerMember http://192.168.1.13:80 
 BalancerMember http://192.168.1.15:80 
 BalancerMember http://192.168.1.16:80 
 BalancerMember http://192.168.1.17:80 
 BalancerMember http://192.168.1.18:80 

 AllowOverride None 
 Order allow,deny 
 allow from all 

 ProxySet lbmethod=byrequests
 </Proxy>

...

</VirtualHost>

Next, I added a new virtual host section to the load balancer’s config:

<VirtualHost *:80>
 ServerName www.pyplate.com

 ProxyRequests Off
 ProxyPass / http://192.168.1.25/

 ErrorLog ${APACHE_LOG_DIR}/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

When the load balancer receives an HTTP request, it examines the domain name in the request to see which virtual host should handle the request. Requests for pages on raspberrywebserver.com are handled by the first virtual host which forwards requests to one of the nodes in the Pi cluster. Requests for pages on http://www.pyplate.com are handled by the second virtual host, which passes requests to a single server which holds the Pyplate web site. This server is a PC, so it’s a lot more powerful than the Raspberry Pi cluster.

I’m just about ready to begin beta testing. If you want to take a look at my new site, you can see it at www.pyplate.com. It’s brand new, so there may be teething problems.

I’ll announce beta testing on the Raspberry Pi forum tomorrow.

 

Advertisements