Security and SSL

Enable HTTPS in Moodle

Reviewed on 1 min read ssl

First check that the domain presents a valid certificate over HTTPS and make a copy of config.php and the database. AutoSSL can only cover eligible names that pass its validation.

To configure the secure address, find and edit the config.php file in the directory where you installed Moodle.

Once inside, find the following line, which contains the app's address:

$CFG->wwwroot = 'http://example.com';

Replace http with https:

$CFG->wwwroot = 'https://example.com';

If Moodle is behind a proxy that terminates TLS, set $CFG->sslproxy only after confirming that architecture; enabling it without a proxy can be insecure or cause errors. Then force the HTTP to HTTPS redirect on the server, run Moodle's HTTPS conversion tool to find embedded content and test access, login, tasks, SCORM, LTI, images and iframe elements.

If the installation lives in a subdirectory, keep that path: for example, https://example.com/campus. Do not run a global replacement of every http string in the database.

The conversion tool is under Site administration > Security > HTTP security > HTTPS conversion tool. Use it first to identify incompatible resources and review its scope before confirming changes. Keep the database backup so that you can go back to the previous state. Moodle documentation.

You may also find useful

Something wrong or out of date? Tell us and we will review it.