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

@@ -1481,7 +1481,11 @@ void App::PrepareHeadersStatic()
AddHeader(L"Status", L"200 OK");
if( AddHeader(config.http_header_send_file, path) )
/*
* FIX ME now we can send full path (apache, lighttpd) and relative path (nginx)
* but this feature for mounting static content probably will be removed
*/
if( AddHeader(config.send_file_header, path) )
log << log2 << "App: sending a file from a static mountpoint: " << path << logend;
}
@@ -1558,7 +1562,7 @@ void App::PrepareHeadersSendFile()
{
AddHeader(L"Status", L"200 OK");
if( AddHeader(config.http_header_send_file, cur.request->x_sendfile) )
if( AddHeader(config.send_file_header, cur.request->x_sendfile) )
log << log2 << "App: sending file: " << cur.request->x_sendfile << logend;
}