I don't think anyone is following what he is saying. I am running into the exact problem with my Moodle installations.
The affected portals are set to "HTTPS" logins only.
They are behind a load balancer so $CFG->sslproxy = 1; must be specified in the config file.
As a result of setting sslproxy=1 moodle expects the wwwroot to be https. If you aren't running an entire site as https you cannot do this so you have to apply a hack found by other users to bypass this check.
To bypass the check you have to comment out ~ lines 822-828 in wwwroot/lib/setuplib.php
// $CFG->sslproxy specifies if external SSL appliance is used
// (That is, the Moodle server uses http, with an external box translating everything to https).
if (empty($CFG->sslproxy)) {
if ($rurl['scheme'] === 'http' and $wwwroot['scheme'] === 'https') {
print_error('sslonlyaccess', 'error');
}
} /*else {
if ($wwwroot['scheme'] !== 'https') {
throw new coding_exception('Must use https address in wwwroot when ssl proxy enabled!');
}
$rurl['scheme'] = 'https'; // make moodle believe it runs on https, squid or something else it doing it
}
*/
If you google around for HTTPS login redirect, or login loop you will find other conversations / issues in the issue tracker.
The above fix combined with the sslproxy setting fixes the login loop problem for a setup behind a loadbalancer using SSL offloading.