You are on page 1of 18

Moodle

Moodle
Deployment Guide

VERSION: 6.0
UPDATED: MARCH 2016
Moodle

Copyright Notices
Copyright © 2002-2016 KEMP Technologies, Inc.. All rights reserved.. KEMP Technologies and the KEMP
Technologies logo are registered trademarks of KEMP Technologies, Inc..
KEMP Technologies, Inc. reserves all ownership rights for the LoadMaster product line including software
and documentation. The use of the LoadMaster Exchange appliance is subject to the license agreement.
Information in this guide may be modified at any time without prior notice.
Microsoft Windows is a registered trademarks of Microsoft Corporation in the United States and other
countries. All other trademarks and service marks are the property of their respective owners.
Limitations: This document and all of its contents are provided as-is. KEMP Technologies has made efforts
to ensure that the information presented herein are correct, but makes no warranty, express or implied,
about the accuracy of this information. If any material errors or inaccuracies should occur in this document,
KEMP Technologies will, if feasible, furnish appropriate correctional notices which Users will accept as the
sole and exclusive remedy at law or in equity. Users of the information in this document acknowledge that
KEMP Technologies cannot be held liable for any loss, injury or damage of any kind, present or prospective,
including without limitation any direct, special, incidental or consequential damages (including without
limitation lost profits and loss of damage to goodwill) whether suffered by recipient or third party or from
any action or inaction whether or not negligent, in the compiling or in delivering or communicating or
publishing this document.
Any Internet Protocol (IP) addresses, phone numbers or other data that may resemble actual contact
information used in this document are not intended to be actual addresses, phone numbers or contact
information. Any examples, command display output, network topology diagrams, and other figures
included in this document are shown for illustrative purposes only. Any use of actual addressing or contact
information in illustrative content is unintentional and coincidental.
Portions of this software are; copyright (c) 2004-2006 Frank Denis. All rights reserved; copyright (c) 2002
Michael Shalayeff. All rights reserved; copyright (c) 2003 Ryan McBride. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE ABOVE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ABOVE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and
should not be interpreted as representing official policies, either expressed or implied, of the above
copyright holders..
Portions of the LoadMaster software are copyright (C) 1989, 1991 Free Software Foundation, Inc. -51
Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA- and KEMP Technologies Inc. is in full compliance
of the GNU license requirements, Version 2, June 1991. Everyone is permitted to copy and distribute
verbatim copies of this license document, but changing it is not allowed.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 2


Moodle

Portions of this software are Copyright (C) 1988, Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms are permitted provided that the above copyright notice
and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and
other materials related to such distribution and use acknowledge that the software was developed by the
University of California, Berkeley. The name of the University may not be used to endorse or promote
products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
Portions of this software are Copyright (C) 1998, Massachusetts Institute of Technology
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Portions of this software are Copyright (C) 1995-2004, Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be
held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications,
and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original
software. If you use this software in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the
original software.
3. This notice may not be removed or altered from any source distribution.
Portions of this software are Copyright (C) 2003, Internet Systems Consortium
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is
hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.

Used, under license, U.S. Patent Nos. 6,473,802, 6,374,300, 8,392,563, 8,103,770, 7,831,712, 7,606,912, 7,346,695, 7,287,084 and
6,970,933

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 3


Moodle

Table of Contents
1 Introduction .................................................................................................................................... 5
1.1 Document Purpose ................................................................................................................. 5
1.2 Intended Audience .................................................................................................................. 5
1.3 Prerequisites ........................................................................................................................... 5
2 Deployment Options ....................................................................................................................... 6
3 Recommended Configuration ......................................................................................................... 7
4 Moodle Template............................................................................................................................ 8
5 Configure the LoadMaster .............................................................................................................. 9
5.1 Create a HTTP Virtual Service ................................................................................................. 9
5.2 Create a HTTPS Virtual Service.............................................................................................. 11
5.3 Other Virtual Service Configuration Options ........................................................................ 13
5.3.1 Transparency and Non-Transparency ........................................................................... 13
5.3.2 Session Persistence ....................................................................................................... 14
5.4 Moodle Server Configuration................................................................................................ 15
5.4.1 Routing .......................................................................................................................... 15
5.4.2 Moodle SSL Configuration............................................................................................. 15
References ............................................................................................................................................ 17
Document History ................................................................................................................................. 18

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 4


Moodle
Introduction

1 Introduction
Moodle is a free open-source software e-learning platform. It is designed to provide educators,
administrators and learners with a single robust, secure and integrated system to create
personalized learning environments.
Moodle is designed to scale and can accommodate extremely large user communities. The KEMP
LoadMaster makes scaling Moodle simpler by load balancing user traffic and offloading the
security overhead.

1.1 Document Purpose


This document provides steps on how to configure the KEMP LoadMaster to load balance the
Moodle platform. This document does not address the deployment of Moodle clusters and
assumes a working knowledge of Moodle configuration editing and some basic LoadMaster
skills. For further information on LoadMaster configuration in general, refer to the
Documentation on the KEMP Support site: https://support.kemptechnologies.com.

1.2 Intended Audience


This document is intended to be read by anyone who is interested in learning about how to load
balance the Moodle platform using a KEMP LoadMaster.

1.3 Prerequisites
There are some requirements that must be met before configuring the LoadMaster to load
balance Moodle:
 The Moodle server(s) must be set up and configured correctly. For more information,
please refer to the Moodle documentation.
 The Active Directory server must be set up and configured correctly. For more
information, please refer to the Microsoft documentation.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 5


Moodle
Deployment Options

2 Deployment Options
A number of options are available to deploy a load balancer in a Moodle environment. These are
described below:

 SSL offload and load balancing: The LoadMaster terminates the SSL session and
communicates with the appropriate server over HTTP. This approach ensures that all
content is SSL encrypted.
 SSL re-encrypt and load balancing: The LoadMaster decrypts incoming traffic and re-
encrypts when forwarding balanced traffic to the Moodle servers.
 Layer 4 SSL balancing: The LoadMaster balances SSL encrypted traffic between the
Moodle servers. All SSL processing is performed by the Moodle servers.
 Load balancing (without SSL offload): In some situations you may not want the
LoadMaster to handle SSL offloading.

This document provides step-by-step instructions for the first and last options above. For further
help on configuring the other methods, please contact KEMP Support.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 6


Moodle
Recommended Configuration

3 Recommended Configuration

Figure 3-1: Example Moodle Topology

A one-arm or two-arm topology can be set up. It is also possible to have a High Availability (HA)
setup which will provide redundancy. For more information on HA and how to configure it, refer
to the High Availability (HA), Feature Description.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 7


Moodle
Moodle Template

4 Moodle Template
KEMP have developed a template containing our recommended settings for Moodle. This
template can be installed on the LoadMaster and can be used when creating each of the Virtual
Services. Using a template automatically populates the settings in the Virtual Services. This is
quicker and easier than manually configuring each Virtual Service. If needed, changes can be
made to any of the Virtual Service settings after using the template.
Released templates can be downloaded from the KEMP documentation page:
http://kemptechnologies.com/documentation.

If you create another Virtual Service using the same template, ensure to
change the Service Name to a unique name.

For more information and steps on how to import and use templates, refer to the Virtual
Services and Templates, Feature Description.
For steps on how to manually add and configure each of the Virtual Services, refer to Section 5.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 8


Moodle
Configure the LoadMaster

5 Configure the LoadMaster


Either a HTTP or HTTPS service can be set up, depending on the requirements. Follow the
instructions in the relevant section below to set up the relevant Virtual Service.

5.1 Create a HTTP Virtual Service


In the main menu of the LoadMaster Web User Interface (WUI), follow the steps below:
1. Select Virtual Services.
2. Click Add New.

Figure 5-1: Virtual Service Parameters

3. Enter a valid Virtual Address.


4. Enter 80 as the Port.
5. Enter a recognizable name, for example HTTP_Moodle.
6. Click Add this Virtual Service.
7. Expand the Advanced Properties section.

Figure 2: Advanced Properties

8. Select 302 Found as the Error Code.


9. Enter https://%h%s and click Set Redirect URL.
10. Expand the Standard Options section.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 9


Moodle
Configure the LoadMaster

Figure 3: Standard Options

11. Remove the tick from the Transparency check box.


12. Expand the Real Servers section.
13. Click Add New.

Figure 5-4: Real Server Parameters

14. Enter the IP address of the back-end servers in the Real Server Address text box.
15. Enter 80 as the Port.
16. Click Add this Real Server.
17. Click OK.
18. Repeat the last four steps to add the other Real Servers.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 10


Moodle
Configure the LoadMaster

5.2 Create a HTTPS Virtual Service

Figure 5-5: SSL offload and load balancing

With this option, all client traffic is encrypted using SSL with the SSL being terminated on the
LoadMaster. The LoadMaster balances the unencrypted traffic between the Moodle servers and
re-encrypts the server replies to the client.
In the main menu of the LoadMaster WUI, follow the steps below:
1. Select Virtual Services.
2. Select Add New.

Figure 5-6: Virtual Service Parameters

3. Enter a valid Virtual Address.


4. Enter 443 as the Port.
5. Enter a recognizable Service Name, such as HTTPS_Moodle.
6. Click Add this Virtual Service.
7. Expand the SSL Properties section.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 11


Moodle
Configure the LoadMaster

Figure 5-7: SSL Properties

8. Select Enabled.
9. Click OK.
10. In the Certificates section, select the relevant certificate and click the right arrow to
move it to the Assigned Certificates box.

The self-signed certificate should be replaced with a proper certificate/key


pair before deployment into a production environment. A single certificate
secures all communications regardless of the number of Moodle servers
deployed.

If there are no certificates listed, one will need to be uploaded. For further
information on certificates, including steps on how to import and generate
one, refer to the SSL Accelerated Services, Feature Description.

11. Click Set Certificates.


12. Expand the Standard Options section.

Figure 5-8: Standard Options

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 12


Moodle
Configure the LoadMaster

13. Select Super HTTP as the Persistence Mode.


14. Expand the Real Servers section.

Figure 5-9: Real Servers Section

15. Click Add New.

Figure 5-10: Real Server Parameters

16. Enter the IP address of the Moodle server in the Real Server Address text box.
17. Enter 80 as the Port.
18. Click Add This Real Server.
19. Click OK.
20. Repeat steps 16 to 19 to add other Real Servers as needed.

5.3 Other Virtual Service Configuration Options


There are other Virtual Service configuration options to consider, such as transparency and
session persistence which are referred to in the sections below.

5.3.1 Transparency and Non-Transparency


A LoadMaster can be deployed in transparent or non-transparent mode. Transparent mode
provides detailed client IP address information in the logs but it requires more configuration
than non-transparent mode. Non-transparent mode requires no changes on the Moodle servers,
but the Moodle logs will show all traffic as coming from the LoadMaster. The table below
outlines some differences between transparent and non-transparent mode.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 13


Moodle
Configure the LoadMaster

Transparent Non-Transparent

The Moodle server sees the client IP address as the The Moodle server sees all requests as coming from the
source of a HTTP request. LoadMaster.

The Moodle server must route all responses to the The Moodle server replies directly back to the
client IP address via the LoadMaster. This requires LoadMaster without any routing changes.
a routing change on the Moodle Server to either:
 Set the default route (gateway) to be
the LoadMaster, or;
 Create static routes for each client
subnet
In practice, setting the default route to be the
LoadMaster is the easiest option.

The Moodle logs contain the source IP address of The Moodle logs show all traffic as coming from the
the client. LoadMaster.

Figure 5-11: Standard Options

Transparency can be enabled/disabled in the Standard Options section of the Virtual Service
modify screen.

5.3.2 Session Persistence


Depending on the configuration of the Moodle cluster, it may be desirable for a user to be
continually served from the same Moodle server. By default, the LoadMaster will not use any
persistence mechanism and a client request may be serviced by any of the Moodle servers in the
cluster. Setting the Persistence Mode to Super HTTP will ensure that a client is serviced by the
same server until the timeout period is reached. When using persistence, the Persistence
Timeout value must match the inactivity timeout set in Moodle.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 14


Moodle
Configure the LoadMaster

5.4 Moodle Server Configuration

Please ensure you have a restorable backup of any configuration before


making these changes.

5.4.1 Routing
If using transparent mode in the LoadMaster, each Moodle server needs a routing update to
provide a route back to the client via the LoadMaster. This can be implemented as a default
route that points to the LoadMaster IP address or routes for the client subnet(s).
If using non-transparent mode on the LoadMaster, no routing changes are required.

5.4.2 Moodle SSL Configuration


The Moodle environment needs to be configured to support SSL proxies and to ensure that all
URLs are HTTPS rather than HTTP. This configuration is stored in config.php which is located in
the moodle/htdocs directory. Two changes are required to this file, as follows:
1. Configure Moodle to not do any SSL processing because that is being performed by the
LoadMaster.
$CFG->sslproxy = 1;
2. Tell Moodle to rewrite all URLs with HTTPS (as this is not done in the LoadMaster in a
Moodle configuration). The config.php file usually selects the reply protocol based on
the client request protocol. Update the code to ensure that all replies are HTTPS.

Before:
if ($_SERVER['HTTPS'] == 'on') {
$CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST'] . '/moodle';
} else {
$CFG->wwwroot = 'http://' . $_SERVER['HTTP_HOST'] . '/moodle';
};

After:
if ($_SERVER['HTTPS'] == 'on') {
$CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST'] . '/moodle';
} else {
$CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST'] . '/moodle';
};

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 15


Moodle
Configure the LoadMaster

The only change in the code is to add an s to the end of http in the else part of the if statement.
Changing the http:// to https:// ensures that all URLs are prefixed by the correct protocol.

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 16


Moodle
References

References
Unless otherwise specified, the following documents can be found at
http://kemptechnologies.com/documentation.

High Availability (HA), Feature Description

SSL Accelerated Services, Feature Description

Virtual Services and Templates, Feature Description

Web User Interface (WUI), Configuration Guide

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 17


Moodle
Document History

Document History
Date Change Reason for Change Version Resp.

Nov 2014 Initial draft First draft of document 1.0 LB

April 2015 Updates made Updated to reflect new template 1.1 LB

Oct 2015 Release updates Updates for 7.1-30 release 3.0 LB

Dec 2015 Release updates Updates for 7.1-32 release 4.0 LB

Jan 2016 Minor change Updated Copyright Notices 5.0 LB

Mar 2016 Release updates Updates for 7.1-34 release 6.0 LB

Copyright © 2002 - 2016 KEMP Technologies, Inc. All Rights Reserved. 18

You might also like