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

Filelib: Curl class does not honour proxybypass option

XMLWordPrintable

    • MOODLE_23_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MDL-38168-master
    • Hide

      WARNING: This test is a bit complicated. I've written it so you can do the test even if you don't normally use a proxy server.

      We are going to use the SCORM activity because it is a convenient way to exercise the curl class and you can tell whether it's using the proxy or not.

      The test instructions contain special lines beginning 'MOODLE 2.3' referring to differences that are expected on that platform.

      1. Go to Site administration / Plugins / Activity modules / SCORM package. Turn on 'Enable external package type' (allowtypeexternal).

      MOODLE 2.3: In addition to this, also ensure you have set 'debugging' option to 'Developer' as otherwise you cannot see the errors that we check below.

      2. In the admin screens under Server/HTTP, or in your config.php (that would be necessary if you have already done 'real' settings in config.php), set the following options:

      proxyhost = does.not.work.example.com
      proxyport = 80
      proxytype = HTTP
      proxybypass = localhost, 127.0.0.1 (default)

      3. Go to any course page, turn editing on, and select to add a 'SCORM package'.

      4. Type anything for name and description. Under 'Type' choose 'External SCORM manifest'.

      5. Under 'URL' type a URL that should normally work without needing a proxy, e.g. the root path of your Moodle server followed by /imsmanifest.xml. For example http://my.moodle.server/imsmanifest.xml.

      6. Hit 'Save and return to course'.

      EXPECTED (except Moodle 2.3): Next to the URL field you should see the error 'Invalid URL specified' with the debug message: Couldn't resolve proxy 'does.not.work.example.com'.

      This indicates that the server was correctly using the http proxy settings (which aren't valid) to retrieve the item.

      MOODLE 2.3: On Moodle 2.3 we expect the following behaviour if it is working correctly: debug text similar to 'cURL request for "http://whatever/imsmanifest.xml" failed with: Couldn't resolve proxy 'does.not.work.example.com' (5)', followed by an undefined property error.

      7. In another tab, go back to the HTTP admin settings and change proxybypass so that it includes the hostname part of the URL you are trying to retrieve; e.g. if the URL is http://my.moodle.server/imsmanifest.xml then you could add ".moodle.server" to the comma-separated list.

      8. Back in the form, hit 'Save and return to course' again.

      EXPECTED (except Moodle 2.3): There is still an error message but now it says 'HTTP/1.1 404 Not Found' indicating that Moodle correctly tried to retrieve the file without using the (bogus) proxy, because it is listed in the bypass list.

      MOODLE 2.3: On Moodle 2.3 we expect the debug text similar to 'cURL request for "http://whatever/imsmanifest.xml" failed, HTTP response code: HTTP/1.1 404 Not Found', followed by an undefined property error.

      BEFORE FIX: The 'Couldn't resolve proxy' error (or Moodle 2.3 equivalent) appears again, indicating that it's still trying to use the proxy server even though this server is on the bypass list.

      Show
      WARNING: This test is a bit complicated. I've written it so you can do the test even if you don't normally use a proxy server. We are going to use the SCORM activity because it is a convenient way to exercise the curl class and you can tell whether it's using the proxy or not. The test instructions contain special lines beginning 'MOODLE 2.3' referring to differences that are expected on that platform. 1. Go to Site administration / Plugins / Activity modules / SCORM package. Turn on 'Enable external package type' (allowtypeexternal). MOODLE 2.3: In addition to this, also ensure you have set 'debugging' option to 'Developer' as otherwise you cannot see the errors that we check below. 2. In the admin screens under Server/HTTP, or in your config.php (that would be necessary if you have already done 'real' settings in config.php), set the following options: proxyhost = does.not.work.example.com proxyport = 80 proxytype = HTTP proxybypass = localhost, 127.0.0.1 (default) 3. Go to any course page, turn editing on, and select to add a 'SCORM package'. 4. Type anything for name and description. Under 'Type' choose 'External SCORM manifest'. 5. Under 'URL' type a URL that should normally work without needing a proxy, e.g. the root path of your Moodle server followed by /imsmanifest.xml. For example http://my.moodle.server/imsmanifest.xml . 6. Hit 'Save and return to course'. EXPECTED (except Moodle 2.3): Next to the URL field you should see the error 'Invalid URL specified' with the debug message: Couldn't resolve proxy 'does.not.work.example.com'. This indicates that the server was correctly using the http proxy settings (which aren't valid) to retrieve the item. MOODLE 2.3: On Moodle 2.3 we expect the following behaviour if it is working correctly: debug text similar to 'cURL request for "http://whatever/imsmanifest.xml" failed with: Couldn't resolve proxy 'does.not.work.example.com' (5)', followed by an undefined property error. 7. In another tab, go back to the HTTP admin settings and change proxybypass so that it includes the hostname part of the URL you are trying to retrieve; e.g. if the URL is http://my.moodle.server/imsmanifest.xml then you could add ".moodle.server" to the comma-separated list. 8. Back in the form, hit 'Save and return to course' again. EXPECTED (except Moodle 2.3): There is still an error message but now it says 'HTTP/1.1 404 Not Found' indicating that Moodle correctly tried to retrieve the file without using the (bogus) proxy, because it is listed in the bypass list. MOODLE 2.3: On Moodle 2.3 we expect the debug text similar to 'cURL request for "http://whatever/imsmanifest.xml" failed, HTTP response code: HTTP/1.1 404 Not Found', followed by an undefined property error. BEFORE FIX: The 'Couldn't resolve proxy' error (or Moodle 2.3 equivalent) appears again, indicating that it's still trying to use the proxy server even though this server is on the bypass list.

      The 'curl' class in filelib.php (which is used, for example, when the SimplePie feed system retrieves files, but also in lots of other places) does not honour the 'proxybypass' option. If the proxy settings are enabled, it always uses the proxy regardless of the URL.

            quen Sam Marshall
            quen Sam Marshall
            Damyon Wiese Damyon Wiese
            Sam Hemelryk Sam Hemelryk
            Rossiani Wijaya Rossiani Wijaya
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.