Description
We are unable to use stack_include on our university's Moodle installation because access to external URLs times out.
Our Moodle server must use an HTTP proxy to access external websites. The proxy is configured in Moodle, and other Moodle functions can access external resources through it. However, the HTTP requests made by stack_include do not appear to fully respect Moodle's proxy settings.
This is not reported as an explicit Moodle or STACK error. Rather, the request to the external resource times out, and consequently stack_include cannot retrieve the requested content.
Environment
- Moodle version: 4.5.4+ (20250530)
- STACK version: 4.9.1 for Moodle 4.0+ (2025040100)
- PHP version: 8.2.30
- Operating system: RHEL 8.10
Relevant code
Our university's IT staff identified the following section of vle_specific.php as the likely source of the problem:
if ($good) {
if (!isset($cache[$translated])) {
// Feel free to apply any proxying here if you want.
// Just remember that $islocalfile might be true and you might do
// something else then.
if ($islocalfile) {
$cache[$translated] = file_get_contents($translated);
} else {
$translated = clean_param($translated, PARAM_URL);
$headers = get_headers($translated);
if (strpos($headers[0], '404') === false) {
$cache[$translated] = download_file_content($translated);
} else {
$cache[$translated] = false;
}
}
}
return $cache[$translated];
}
$cache[$translated] = false;
return false;
In particular, the call
$headers = get_headers($translated);
appears to access the external URL directly, without using Moodle's configured HTTP proxy. In an environment where direct outbound HTTP access is not permitted, this request times out before the content can be retrieved.
The comment in this section also seems to indicate that proxy handling has not yet been implemented here:
// Feel free to apply any proxying here if you want.
Expected behaviour
All HTTP requests made by stack_include, including the request used to check the response headers, should respect Moodle's standard proxy configuration.
Actual behaviour
The request to the external URL times out because it appears to bypass the HTTP proxy configured in Moodle. As a result, stack_include cannot be used on our Moodle installation.
Request
Would it be possible to replace the direct HTTP access in this section with Moodle's standard HTTP client or another method that respects Moodle's proxy settings?
Please let us know if any additional configuration details or diagnostic information would be helpful.
Description
We are unable to use
stack_includeon our university's Moodle installation because access to external URLs times out.Our Moodle server must use an HTTP proxy to access external websites. The proxy is configured in Moodle, and other Moodle functions can access external resources through it. However, the HTTP requests made by
stack_includedo not appear to fully respect Moodle's proxy settings.This is not reported as an explicit Moodle or STACK error. Rather, the request to the external resource times out, and consequently
stack_includecannot retrieve the requested content.Environment
Relevant code
Our university's IT staff identified the following section of
vle_specific.phpas the likely source of the problem:In particular, the call
appears to access the external URL directly, without using Moodle's configured HTTP proxy. In an environment where direct outbound HTTP access is not permitted, this request times out before the content can be retrieved.
The comment in this section also seems to indicate that proxy handling has not yet been implemented here:
// Feel free to apply any proxying here if you want.Expected behaviour
All HTTP requests made by
stack_include, including the request used to check the response headers, should respect Moodle's standard proxy configuration.Actual behaviour
The request to the external URL times out because it appears to bypass the HTTP proxy configured in Moodle. As a result,
stack_includecannot be used on our Moodle installation.Request
Would it be possible to replace the direct HTTP access in this section with Moodle's standard HTTP client or another method that respects Moodle's proxy settings?
Please let us know if any additional configuration details or diagnostic information would be helpful.