Introduction
Actually, the focus of this article is to discuss about how to solve an error. The error itself is an error where it appear upon accessing a certain URL address. That URL address is representing an address of a web page. Furthermore, that web page is a web application running using a specific framework. In this case, the framework of that web application is Moodle. So, there is a web application running using a Moodle framework. Instead of displaying the web page in a normal way, unfortunately it display an error message. The error message is :
For security reasons only https connection are allowed, sorry.
The following is the actual error message where it available after the attempt to access the web page as follows :
Error Background
How the error message exist as in the previous part occurs ?. Well, in this case, there are two scenarios where the output or the result can occur upon accessing the URL address of a Moodle-based web application which is running using an HTTPS URL address. Actually, there can be another different type of scenarios where the above error appear. But in this article, the description of the situation only appear in two different type of scenarios.
First Scenario
The first one is the simple scenario with the following diagram :
In this case, the description for the above server schema where an error appear exist as follows :
-
There is a device accessing the URL of ‘https://www.mymoodlesites.com’.
-
The request is going on through the internet.
-
The server where has the address of ‘https://www.mymoodlesites.com’ will accept the request.
-
Instead of displaying the normal web page, it display the page with an error message as it exist above.
Second Scenario
While the second one is another simple scenario with the following diagram :
-
Similar with the previous scenario, there is a device accessing the URL of ‘https://www.mymoodlesites.com’.
-
The request is also going on through the internet.
-
The server where has the address of ‘https://www.myothersites.com’ will respond to the request. Instead of processing the request by displaying the suitable page, it pass the request to another server. It is because of the end part of the URL address of ‘/mymoodlesites’. There is an Apache Webserver’s reverse proxy definition which is forcing the request going into the other server. The server’s location is in ‘192.168.x.y’ which exist coincidentally in the same network segment. But that does not matter as long as both of the server can communicate. The following is the sample of the reverse proxy’s configuration :
ProxyPass /mymoodlesites http://192.168.x.y/mymoodlesites ProxyPassReverse /mymoodlesites http://192.168.x.y/mymoodlesites
So, the server will pass the request to the other server which is the real server serving the web page.
-
Instead of displaying the normal web page, it display the page with an error message as it exist above.
Solution
So, how is the solution to solve the above error message ?. The solution is very simple. The following are the steps to solve the error message :
-
Access the server.
-
Go to the root directory of the Moodle’s web application source code.
-
Find and open the file with the name of ‘config.php’.
-
Search the following part of source code : Edit the file by removing the comment on the following line :
It is a way to activate or to make sure that the web server will parse and execute that line of configuration
// The following lines are for handling email bounces. // $CFG->handlebounces = true; // $CFG->minbounces = 10; // $CFG->bounceratio = .20; // The next lines are needed both for bounce handling and any other email to module processing. // mailprefix must be EXACTLY four characters. // Uncomment and customise this block for Postfix // $CFG->mailprefix = 'mdl+'; // + is the separator for Exim and Postfix. // $CFG->mailprefix = 'mdl-'; // - is the separator for qmail // $CFG->maildomain = 'youremaildomain.com'; // // Enable when setting up advanced reverse proxy load balancing configurations, // it may be also necessary to enable this when using port forwarding. // $CFG->reverseproxy = true; // // Enable when using external SSL appliance for performance reasons. // Please note that site may be accessible via http: or https:, but not both! $CFG->sslproxy = true;
-
Remove the comment in the following line of the configuration :
// $CFG->reverseproxy = true;
So, the configuration line will exist as follows :
$CFG->reverseproxy = true;
-
So, the overall part will be in the following appearance :
// The following lines are for handling email bounces. // $CFG->handlebounces = true; // $CFG->minbounces = 10; // $CFG->bounceratio = .20; // The next lines are needed both for bounce handling and any other email to module processing. // mailprefix must be EXACTLY four characters. // Uncomment and customise this block for Postfix // $CFG->mailprefix = 'mdl+'; // + is the separator for Exim and Postfix. // $CFG->mailprefix = 'mdl-'; // - is the separator for qmail // $CFG->maildomain = 'youremaildomain.com'; // // Enable when setting up advanced reverse proxy load balancing configurations, // it may be also necessary to enable this when using port forwarding. $CFG->reverseproxy = true; // // Enable when using external SSL appliance for performance reasons. // Please note that site may be accessible via http: or https:, but not both! $CFG->sslproxy = true;
- Last but not least, just try and access the web page once more. If there are no more errors appear, it will display the normal display of the web page.
One thought on “How to Change Access Moodle-based Web Application from HTTP to HTTPS”