Configuring webservers on vmware workstation to test loadbalancing

In this post we shall see how to install Apache on a linux server and configure “IP-based” virtual hosts, which can be used as pool members on the bigip. Ubuntu desktop edition can be used, however, a ubuntu minimal edition is preferred as it can run on just 512 MB of ram even using a display manager like LXDE.

1. Configure Networking:
To use IP-based virtual hosting, logical network interfaces have to be created on top the physical interface of the vmware linux guest.

Add logical interfaces  and configure ip addresses in the /etc/networks/interfaces file.

auto eth0
iface eth0 inet static
address 10.10.1.10
netmask 255.255.255.0
gateway 10.10.1.1
dns-nameservers 74.82.42.42 4.2.2.2

auto eth0:1
iface eth0:1 inet static
address 10.10.1.11
netmask 255.255.255.0

auto eth0:2
iface eth0:2 inet static
address 10.10.1.12
netmask 255.255.255.0

auto eth0:3
iface eth0:3 inet static
address 10.10.1.13
netmask 255.255.255.0

auto eth0:4
iface eth0:4 inet static
address 10.10.1.14
netmask 255.255.255.0

auto eth0:5
iface eth0:5 inet static
address 10.10.1.15
netmask 255.255.255.0

up route add -net 0.0.0.0/0 gw 10.10.1.1 dev eth0

Restart networking using sudo ifdown eth0 and sudo ifup eth0.

The output of ip addr show should be as follows

2: eth0: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:9c:68:fa brd ff:ff:ff:ff:ff:ff
inet 10.10.1.10/24 brd 10.10.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.10.1.11/24 brd 10.10.1.255 scope global secondary eth0:1
valid_lft forever preferred_lft forever
inet 10.10.1.12/24 brd 10.10.1.255 scope global secondary eth0:2
valid_lft forever preferred_lft forever
inet 10.10.1.13/24 brd 10.10.1.255 scope global secondary eth0:3
valid_lft forever preferred_lft forever
inet 10.10.1.14/24 brd 10.10.1.255 scope global secondary eth0:4
valid_lft forever preferred_lft forever
inet 10.10.1.15/24 brd 10.10.1.255 scope global secondary eth0:5
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe9c:68fa/64 scope link
valid_lft forever preferred_lft forever

2. Add entries to /etc/hosts file:
Append the following entries in /etc/hosts file

10.10.1.11      server1
10.10.1.12      server2
10.10.1.13      server3
10.10.1.14      server4
10.10.1.15      server5

3. Install Apache software:

sudo apt-get update
sudo apt-get install apache2

4. Working with directories:
Create directories for the virtual hosts

sudo mkdir -p /var/www/server1-files/{cgi-bin,html/monitor}
sudo mkdir -p /var/www/server2-files/{cgi-bin,html/monitor}
sudo mkdir -p /var/www/server3-files/{cgi-bin,html/monitor}
sudo mkdir -p /var/www/server4-files/{cgi-bin,html/monitor}
sudo mkdir -p /var/www/server5-files/{cgi-bin,html/monitor}

Change owner to current user

sudo chown -R $USER:$USER /var/www/server1-files
sudo chown -R $USER:$USER /var/www/server2-files
sudo chown -R $USER:$USER /var/www/server3-files
sudo chown -R $USER:$USER /var/www/server4-files
sudo chown -R $USER:$USER /var/www/server5-files

Change permissions

sudo chmod -R 755 /var/www

5. Create index pages under respective directories
Create an index.html page under /var/www/server1-files/html directory and add the following text

<html>
<head>
<title>Server 10.10.1.11</title>
</head>
<body>
<h1>Success!  The 10.10.1.11 virtual host is working!</h1>
</body>
</html>

Create a bigip.html page under /var/www/server1-files/html/monitor directory and add the following text

Server Up

Similarly, create index.html and bigip.html files under  server2-files,  server3-files,  server4-files,  server5-files directories.

6. Create virtual host files
Create a virtual host file /etc/apache2/sites-available/server1.conf as follows

<VirtualHost 10.10.1.11:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/server1-files/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
server1-files/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /var/www/server1-files/cgi-bin/
<directory “=”” <span=”” class=”hiddenSpellError” pre=”” data-mce-bogus=”1″>usr/lib/cgi-bin”>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

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>

Similarly, create virtual hosts server2.conf, server3.conf, server4.conf, server5.conf with ip addresses 10.10.1.12, 10.10.1.13, 10.10.1.14, 10.10.1.15 under /etc/apache2/sites-available/ directory.

7. Enable virtual hosts:

sudo a2ensite server1.conf
sudo a2ensite server2.conf
sudo a2ensite server3.conf
sudo a2ensite server4.conf
sudo a2ensite server5.conf

8. Restart Apache service

sudo service apache2 restart

9. Testing:
Access the sites using a browser by pointing to
http://10.10.1.11/ and http://10.10.1.11/monitor/bigip.html
http://10.10.1.12/ and http://10.10.1.12/monitor/bigip.html
http://10.10.1.13/ and http://10.10.1.13/monitor/bigip.html
http://10.10.1.14/ and http://10.10.1.14/monitor/bigip.html
http://10.10.1.15/ and http://10.10.1.15/monitor/bigip.html

Downloads:
Ubuntu Minimal – pre-configured Ubuntu minimal installation in .ova format.
Ubuntu server config files – (files necessary to setup and test loadbalancing)

References:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
http://httpd.apache.org/docs/2.2/vhosts/examples.html

17 thoughts on “Configuring webservers on vmware workstation to test loadbalancing

  1. Sarmad

    Hi, great work, really helpful, but the login account doesn’t allow me to change anything, i’d like to change some routes and adjust some settings, can you share the admin username/password ?

    Reply
    1. jana bollineni Post author

      The root account is by default kept locked in Ubuntu. You need to use sudo for elevated privileges with the username violet. You can also unlock the root account using sudo if you want to.

      Reply
  2. Sarmad

    Hi, great work, really helpful, can you share the admin username/password, I’d like to change some routes and some settings

    Reply
    1. jana bollineni Post author

      Hi,

      The root account is kept locked as it is in Ubuntu. You need to use ‘sudo’ for elevated priviliges while executing commands. The username and password is violet/violet as mentioned in the blog.

      Thank you.

      Reply
  3. Gajendra

    Hi Jana,

    I have installed ubuntu-trusty-mini on Vmware ws 11 successfully also installed the BIG IP image,everything seems to be up.But when i tried to access VIP i.e. 192.168.0.177 showing an error however the VIP hits the server and the count also increases in pool statistics. Am i missed something or need to install the Apache software

    Reply
  4. Gajendra

    Hi Jana,

    Thanks a lot for prompt response,after enabling SNAT automap,everything seems to be fine.Now started further labs.Thanks once again.

    Reply
  5. Kikus

    Hi,

    I’ve tried to open the *.ova using VMware® Workstation 12 Pro and it doesn’t work, it says “Operating System not found” on the CLI.

    Can you please have a look, thanks.

    Reply
    1. jana bollineni Post author

      Hi,

      I tested the .ova again and it works fine on my Workstation 12 Pro. I’ve added the md5 value of .ova file to the shared folder. Could you run an md5sum to make sure the image is not corrupted while downloading.

      Thank you

      Reply
  6. Vincent

    Hello!

    Thanks a lot, this is working very well. Could you also indicate how the page could respond to HTTPS requests as well?

    Thank you in advance!

    Reply
  7. Dominik

    Hi,

    “Create a bigip.html page under /var/www/server1-files/html/monitor directory and add the following text

    Server Up”

    I found mistake in server 1 and server 2 files.
    10.10.1.11 server1
    10.10.1.12 server2
    It was “Serverasd Up: and pool mmeber was offline.
    You have to only edit documents and correct to “Server Up”.
    Monitor is set to received string Server Up. Thank you very much . And of course automap. Good job !

    Regards,
    Dominik

    Reply
    1. jana bollineni Post author

      Hi,

      I use the same Ubuntu image for testing and sometimes for training. I might have created the .ova image with the content in the bigip.html file modified.
      Anyway, thanks for checking that.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s