[CORE] Fix X-Sendfile for nginx, using the X-Accel-Redirect header
This commit is contained in:
parent
3e5ce46e98
commit
a5259073df
|
@ -191,14 +191,19 @@ The ones that you may want to set are listed below for clarity.
|
||||||
until they get their databases fixed up. See "UTF-8 database" above for
|
until they get their databases fixed up. See "UTF-8 database" above for
|
||||||
details.
|
details.
|
||||||
|
|
||||||
* `schemacheck` (enum["runtime", "script"], default "runtime"): when to let
|
* `schemacheck` (enum["runtime", "script"], default "runtime"): when
|
||||||
plugins check the database schema to add tables or update them. 'runtime'
|
to let plugins check the database schema to add tables or update
|
||||||
can be costly (plugins check the schema on every hit, adding potentially
|
them. 'runtime' can be costly (plugins check the schema on every
|
||||||
several db queries, some quite long), but not everyone knows how to run a
|
hit, adding potentially several db queries, some quite long), but
|
||||||
script or has the access in their hosting environment to do so. If you can,
|
not everyone knows how to run a script or has the access in their
|
||||||
set this to 'script' and run scripts/checkschema.php whenever you install
|
hosting environment to do so. If you can, set this to 'script' and
|
||||||
or upgrade a plugin.
|
run scripts/checkschema.php whenever you install or upgrade a
|
||||||
|
plugin.
|
||||||
|
|
||||||
|
* `x-static-delivery` (string, default null): when a string, use this
|
||||||
|
as the header with wich to serve static files. Possible values are
|
||||||
|
'X-Sendfile' (for Apache and others) and 'X-Accel-Redirect' (for
|
||||||
|
nginx).
|
||||||
|
|
||||||
syslog
|
syslog
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -202,11 +202,16 @@ class AttachmentAction extends ManagedAction
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include $filepath in the response, for viewing and downloading
|
* Include $filepath in the response, for viewing and downloading.
|
||||||
|
* If provided, $filesize is used to size the HTTP request,
|
||||||
|
* otherwise it's value is calculated
|
||||||
*/
|
*/
|
||||||
static function sendFile(string $filepath, $filesize) {
|
static function sendFile(string $filepath, $filesize) {
|
||||||
if (common_config('site', 'use_x_sendfile')) {
|
if (is_string(common_config('site', 'x-static-delivery'))) {
|
||||||
header('X-Sendfile: ' . $filepath);
|
$relative_path = end(explode(INSTALLDIR, $filepath));
|
||||||
|
common_debug("Using Static Delivery with header: '" .
|
||||||
|
common_config('site', 'x-static-delivery') . ": {$relative_path}'");
|
||||||
|
header(common_config('site', 'x-static-delivery') . ": {$relative_path}");
|
||||||
} else {
|
} else {
|
||||||
if (empty($filesize)) {
|
if (empty($filesize)) {
|
||||||
$filesize = filesize($filepath);
|
$filesize = filesize($filepath);
|
||||||
|
|
|
@ -84,6 +84,6 @@ class Attachment_thumbnailAction extends AttachmentAction
|
||||||
header('Expires: 0');
|
header('Expires: 0');
|
||||||
header('Content-Transfer-Encoding: binary');
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
|
||||||
AttachmentAction::sendFile($filepath, $size);
|
AttachmentAction::sendFile($filepath, $filesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,7 +575,7 @@ class ImageFile extends MediaFile
|
||||||
|
|
||||||
$filename = basename($this->filepath);
|
$filename = basename($this->filepath);
|
||||||
$extension = File::guessMimeExtension($this->mimetype);
|
$extension = File::guessMimeExtension($this->mimetype);
|
||||||
$outname = "thumb-{$this->fileRecord->getID()}-{$width}x{$height}-{$filename}." . $extension;
|
$outname = "thumb-{$this->fileRecord->getID()}-{$width}x{$height}-{$filename}";
|
||||||
$outpath = File_thumbnail::path($outname);
|
$outpath = File_thumbnail::path($outname);
|
||||||
|
|
||||||
// The boundary box for our resizing
|
// The boundary box for our resizing
|
||||||
|
|
Loading…
Reference in New Issue
Block a user