Add support for alternative download domain #3
@ -291,10 +291,10 @@ class BuildsRenderer {
|
||||
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
|
||||
}
|
||||
|
||||
// Try to use the CDN host, otherwise use existing host
|
||||
$host_id = getenv('HOST_CDN') ?: getHostId();
|
||||
|
||||
$uri = $protocol . "://$host_id" . "$request_uri";
|
||||
// Use specific host provided for file downloads if present, otherwise serve
|
||||
// files from the same domain as the website itself.
|
||||
$download_host = getenv('DOWNLOAD_FILE_DOMAIN') ?: getHostId();
|
||||
$uri = $protocol . "://$download_host" . "$request_uri";
|
||||
|
||||
$escaped_file_name = htmlspecialchars($build->file_name);
|
||||
|
||||
|
@ -87,13 +87,6 @@ function handleRequest() {
|
||||
|
||||
$url = parse_url($_SERVER['REQUEST_URI']);
|
||||
|
||||
// Fail requests directed at HOST_CDN if they do not match the /download/*/* pattern
|
||||
$pattern = "/^\/download\/[^\/]+\/[^\/]+$/";
|
||||
if (getenv('HOST_CDN') && $_SERVER['HTTP_HOST'] == getenv('HOST_CDN') && !preg_match($pattern, $url['path'])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($url['path'] === '/') {
|
||||
// Root URL
|
||||
header('Location: /download/daily/');
|
||||
|
Loading…
Reference in New Issue
Block a user