added possibility to send static files to nginx via X-Accel-Redirect header

added to config:
int send_file_mode;
    // 0 - full path to a file in send_file_header header
    // 1 - relative path to a file in send_file_header (need http_send_file_relative_prefix set) (used for nginx)
std::wstring send_file_header;
    // default: X-SENDFILE
    // for Apache set: X-SENDFILE
    // for Lighttpd set: X-LIGHTTPD-send-file
    // for Nginx set: X-Accel-Redirect
std::wstring send_file_relative_prefix;
    // relative prefix used for sending static files if send_file_mode is 1
    // default: "upload-files-internal"
This commit is contained in:
2021-09-15 20:28:34 +02:00
parent 7673264fe1
commit 55ac9a61ed
6 changed files with 90 additions and 8 deletions

View File

@@ -71,11 +71,21 @@ void Download::MakeGet()
}
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
bool is_thumb = (cur->request->item.item_content.file_has_thumb && cur->request->IsParam(L"thumb"));
if( cur->request->item.item_content.file_has_thumb && cur->request->IsParam(L"thumb") )
system->MakeFilePath(cur->request->item, cur->request->x_sendfile, true);
if( config->send_file_mode == 0 )
{
system->MakeFilePath(cur->request->item, cur->request->x_sendfile, is_thumb);
}
else
system->MakeFilePath(cur->request->item, cur->request->x_sendfile);
if( config->send_file_mode == 1 )
{
system->MakeRelativeFilePath(cur->request->item, config->send_file_relative_prefix, cur->request->x_sendfile, is_thumb);
}
else
{
log << log1 << "Download: send_file_mode in the config should be either 0 or 1" << logend;
}
}