[ticket/9790] Support for nginx's X-Accel-Redirect header for attachments.

PHPBB3-9790
This commit is contained in:
Andreas Fischer 2011-01-13 00:46:19 +01:00
parent 19931713db
commit 6bbdc129c0
2 changed files with 18 additions and 0 deletions

View file

@ -3,6 +3,14 @@
# from your system's nginx.conf.
# Tested with nginx 0.8.35.
# If you want to use the X-Accel-Redirect feature,
# add the following to your config.php.
#
# define('PHPBB_ENABLE_X_ACCEL_REDIRECT', true);
#
# See http://wiki.nginx.org/XSendfile for the details
# on X-Accel-Redirect.
http {
# Compression - requires gzip and gzip static modules.
gzip on;

View file

@ -229,6 +229,16 @@ function send_file_to_browser($attachment, $upload_dir, $category)
if (!set_modified_headers($attachment['filetime'], $user->browser))
{
// We make sure those have to be enabled manually by defining a constant
// because of the potential disclosure of full attachment path
// in case support for features is absent in the webserver software.
if (defined('PHPBB_ENABLE_X_ACCEL_REDIRECT') && PHPBB_ENABLE_X_ACCEL_REDIRECT)
{
// X-Accel-Redirect - http://wiki.nginx.org/XSendfile
header('X-Accel-Redirect: ' . $user->page['root_script_path'] . $upload_dir . '/' . $attachment['physical_filename']);
exit;
}
// Try to deliver in chunks
@set_time_limit(0);