Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-28691

Moodle network does not work on the server which connects to Internet via proxy.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.9.12
    • Fix Version/s: STABLE backlog
    • Component/s: MNet
    • Labels:
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      A moodle server that is connected to the Internet via proxy server cannot use Moodle network function.
      For example, my moodle server's address is http://www.suzuka-ct.ac.jp/mech/moodle. the server is connected to the Internet by using reverse-proxy server.
      The server needs using proxy setting($CFG->proxyhost, $CFG->proxyport) for getting the language package in automatically.

      [Cause and countermeasure of this problem]

      1) file_get_contents() -> download_file_content()

      mnet/peers.php,function bootstrap()

                  // TODO: In reality, this will be prohibitively slow... need another
                  // default - maybe blank string
      //          $homepage = file_get_contents($wwwroot);
      // Adding by Shirai from here
                  global $CFG;
                  if (!empty($CFG->proxyhost)) $homepage = download_file_content($wwwroot);
                      else                     $homepage = file_get_contents($wwwroot);
      // Adding by Shirai for here
                  if (!empty($homepage)) {
                      $count = preg_match("@<title>(.*)</title>@siU", $homepage, $matches);
                      if ($count > 0) {
                          $this->name = $matches[1];
                          $this->updateparams->name = addslashes($matches[1]);
                      }
                  }

      file_get_contents() cannot work via proxy, then my moodle site did not work at all.

      2) adding cURL options for proxy (if not empty($CFG->proxyhost), not empty($CFG=>proxyuser), respectively.

          curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost.':'.$CFG->proxyport);
          curl_setopt($ch, CURLOPT_PROXYUSERPWD, $CFG->proxyuser.':'.$CFG->proxypassword);

      In function mnet_get_public_key() : mnet/lib.php and function send() : mnet/xmlrpc/client.php

      --------------

      Only this three points are needed to modify for using proxy.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            shirai Tatsuya Shirai
            Participants:
            Component watchers:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: