Shibboleth Apache Multiple Virtual Host configuration for Moodle
About
Below are steps to configure a shibboleth SP to work with multiple Apache virtual hosts using a single entityID and an Assertion Consumer Service (ACS) and shibboleth’s NativeSPApplicationOverride. More information can be found here regarding NativeSPApplicationOverride
You will need to do this if you are running more than one virtual named host and each virtual host is running it’s own Moodle instance.
In this example, we will use the server names http://www.moodle1.ucla.edu and http://www.moodle2.ucla.edu with an entityID of http://www.moodle1.ucla.edu.
Note: You will need shibboleth installed and 2 instances of Moodle installed. You will also have needed to request attribute releases for the entityID and the ACS where http://www.moodle1.ucla.edu is the entityID and http://www.moodle2.ucla.edu is the ACS that is associated with the http://www.moodle1.ucla.edu entityID.
shibboleth2.xml file configuration
Below are the changes I needed to make in the default configuration file. All other settings were left as default from the shibboleth 2.1 installation.
Modifying the host name for the 2 virtual host web servers
<RequestMapper type="Native">
<RequestMap applicationId="default">
<Host name="www.moodle1.ucla.edu"><Path name="default" authType="shibboleth" requireSession="true"/></Host>
<Host name="www.moodle2.ucla.edu" applicationId="moodle2" authType="shibboleth" requireSession="true"/>
</RequestMap></RequestMapper>
Entering entityID
<ApplicationDefaults id="default" policyId="default"entityID="http://www.moodle1.ucla.edu"REMOTE_USER="Shib-eduPersonPrincipalName"signing="false" encryption="false">
Point to Production AIS IdP
<SessionInitiator type="Chaining" Location="/Login" isDefault="true" id="default"relayState="cookie" entityID="urn:mace:incommon:ucla.edu">
h3.Pulling the MetadataProvider ID Information
<MetadataProvider id="incommon" type="XML"xmlns="urn:mace:shibboleth:2.0:metadata"url="http://wayf.incommonfederation.org/InCommon/InCommon-metadata.xml"backingFilePath="/etc/shibboleth/InCommon-metadata.xml"reloadInterval="28800"></MetadataProvider>
Setup the ApplicationOverride
<ApplicationOverride id="moodle2" entityID="http://www.moodle1.cdh.ucla.edu"/>
Save and close the file. Check the shibboleth configuration file for errors: shibd -t and restart the shibboleth service: service shibd restart
Apache Virtual Host Configuration
Note: The Moodle root for www.moodle1.ucla.edu is at /var/www/html/moodle1 and the Moodle root for www.moodle2.ucla.edu is at /var/www/html/moodle2.
At the bottom of the httpd.conf file there should be a Virtual Hosts section. You will need to uncomment and add the following lines in your httpd.conf file.
# Use name-based virtual hosting.*NameVirtualHost *:80*
<VirtualHost *:80>ServerAdmin webmasterhumnet.ucla.edu@DocumentRoot /var/www/html/moodle1ServerName www.moodle1.ucla.edu
This section allows for the use of .htaccess files to enable Shibboleth on directories<Directory "/var/www/html/moodle1">Options AllAllowOverride AllOrder allow,denyAllow from all</Directory>
This section is required by Moodle to use Shibboleth authentication along
with local authentication by only restricting the index.php file to shib auth.<Directory /var/www/html/moodle1/auth/shibboleth/index.php>
AuthType shibboleth
ShibRequireSession On
require valid-user</Directory></VirtualHost>
<VirtualHost *:80>ServerAdmin webmasterhumnet.ucla.edu@DocumentRoot /var/www/html/moodle2ServerName www.moodle2.ucla.edu
This section allows for the use of .htaccess files to enable Shibboleth on directories<Directory "/var/www/html/moodle2">
Options All
AllowOverride All
Order allow,deny
Allow from all</Directory>
- This section is required by Moodle to use Shibboleth authentication along*
- with local authentication by only restricting the index.php file to shib auth.*
<Directory /var/www/html/moodle2/auth/shibboleth/index.php>
AuthType shibboleth
ShibRequireSession On
require valid-user</Directory></VirtualHost>
Save and close the file and check the apache configuration: httpd -t Then restart apache. sudo /sbin/service httpd restart
CCLE UCLAlogin.php page
If you are going to use CCLE UCLAlogin.php page you will need to edit the htpswwwroot variable and hard code the server name.
Example for www.moodle1.ucla.edu
Comment this line://$CFG->httpswwwroot = str_replace("http://", "https://", $CFG-httpswwwroot);
Enter this instead:$CFG->httpswwwroot ="http://www.moodle1.ucla.edu";