Skip to content

Commit 992c615

Browse files
committed
Internal: Fix support for X-Sendfile headers - refs #5673
1 parent e797ca0 commit 992c615

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

documentation/installation_guide.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,23 @@ <h2><a id="14._Improving_files_download"></a>12. Improving files download effici
674674
<pre>
675675
$_configuration['enable_x_sendfile_headers'] = true;
676676
</pre>
677-
If you have issues with files taking a long time to download, make sure you reconfigure your webserver and add this line. You should see a notable difference in download time.
677+
If you have issues with files taking a long time to download, make sure you reconfigure your webserver and add this line. You should see a notable difference in download time.<br>
678+
679+
Your webserver must be configured to support X-Sendfile, both by enabling the module and setting options in your web server's configuration.<br>
680+
If you are running Apache 2.4 on Ubuntu, for example, this would mean installing and enabling the module:
681+
<pre>
682+
sudo apt install libapache2-mod-xsendfile
683+
sudo a2enmod xsendfile
684+
</pre>
685+
Then in your active vhost for Chamilo, you would have to add the following lines, where the path is the same as your DocumentRoot (we use /var/www/chamilo in this example):
686+
<pre>
687+
XSendFile On
688+
XSendFilePath /var/www/chamilo
689+
</pre>
690+
Then restart Apache:
691+
<pre>
692+
sudo systemctl restart apache2
693+
</pre>
678694
<hr style="width: 100%; height: 2px;" />
679695
<h2><a id="15._Videoconference"></a>13. Videoconference</h2>
680696
<p>

documentation/installation_guide_es_ES.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,23 @@ <h2><a id="14._Improving_files_download"></a>12. Mejora de la eficacia de descar
796796
<pre>$_configuration['enable_x_sendfile_headers'] = true;</pre>
797797
Si tiene problemas con los archivos que tardan mucho tiempo en descargarse, asegúrese de reconfigurar su
798798
servidor web y agregar esta línea. Debería ver una diferencia notable en el tiempo de descarga.
799+
800+
El servidor web tiene que ser configurado para soportar X-Sendfile, por activar el módulo y por configurar opciones en su configuración.<br>
801+
Si tiene Apache 2.4 en Ubuntu, por ejemplo, tendría que ser algo así:
802+
<pre>
803+
sudo apt install libapache2-mod-xsendfile
804+
sudo a2enmod xsendfile
805+
</pre>
806+
De ahí, en su vhost para Chamilo, tendría que añadir las líneas siguientes, donde el path es el mismo que su DocumentRoot (usamos /var/www/chamilo en este ejemplo):
807+
<pre>
808+
XSendFile On
809+
XSendFilePath /var/www/chamilo
810+
</pre>
811+
Luego reiniciar Apache:
812+
<pre>
813+
sudo systemctl restart apache2
814+
</pre>
815+
799816
<hr style="width: 100%; height: 2px;" />
800817

801818
<h2><a id="15._Videoconference"></a>13. Videoconferencia</h2>

documentation/installation_guide_fr_FR.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,30 @@ <h2><a id="13._Changing_language_names_order"></a>11. Changer l'ordre nom/préno
720720
<hr style="width: 100%; height: 2px;" />
721721
<h2><a id="14._Improving_files_download"></a>12. Améliorer la performance des téléchargements de fichiers</h2>
722722
<div>
723-
File download can be very slow when passing through a PHP script to control permissions. One solution to this
724-
is to use the X-Sendfile header, which depends on a module on the webserver. <a href="https://stackoverflow.com/a/3731639/1406662">Check https://stackoverflow.com/a/3731639/1406662 for more details on implementing Sendfile</a>.
725-
Chamilo LMS 1.9.8 (and following versions) supports the X-Sendfile headers, but requires a specific line of configuration to be
726-
added to configuration.php:
723+
Le téléchargement de fichiers peut &ecirc;tre très lent quand il passe au travers d'un script PHP qui contr&ocirc;le les permissions. One solution to this
724+
Une solution pour cela est d'utiliser les en-t&ecirc;tes X-Sendfile, qui dépendent d'un module du serveur web. <a href="https://stackoverflow.com/a/3731639/1406662">Lisez https://stackoverflow.com/a/3731639/1406662 pour plus de d&eacute;tails concernant son impl&eacut;mentation</a>.
725+
Chamilo LMS 1.9.8 (et les versions suivantes) supporte les en-t&ecirc;tes X-Sendfile, mais exige une ligne de configuration spéciale à ajouter à configuration.php :
727726
<pre>
728727
$_configuration['enable_x_sendfile_headers'] = true;
729728
</pre>
730-
If you have issues with files taking a long time to download, make sure you reconfigure your webserver and add this line. You should see a notable difference in download time.
729+
Si vous avez des soucis avec le téléchargement trop lent de fichiers, essayez cette option. Vous devriez observer une différence sensible dans les temps de téléchargement.
730+
731+
Votre serveur web doit &ecirc;tre configuré pour supporter X-Sendfile, en activant le moédule correspondant ainsi qu'une configuration de votre vhost.<br>
732+
733+
Si vous utilisez Apache 2.4 sur Ubuntu, par exemple, ça voudrait dire installer et activer le module X-Sendfile :
734+
<pre>
735+
sudo apt install libapache2-mod-xsendfile
736+
sudo a2enmod xsendfile
737+
</pre>
738+
Ensuite il faut configurer le vhost actif de Chamilo en ajoutant les lignes suivantes, où le path est le m&ecirc;me que votre DocumentRoot (nous utilisons /var/www/chamilo dans cet exemple) :
739+
<pre>
740+
XSendFile On
741+
XSendFilePath /var/www/chamilo
742+
</pre>
743+
Puis red&eacute;marrer Apache :
744+
<pre>
745+
sudo systemctl restart apache2
746+
</pre>
731747
</div>
732748
<hr style="width: 100%; height: 2px;" />
733749
<h2><a id="15._Videoconference"></a>13. Vidéo-conférence</h2>

main/inc/lib/document.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public static function file_send_for_download(
360360
$fixLinksHttpToHttps = false,
361361
$extraHeaders = []
362362
) {
363-
session_write_close(); //we do not need write access to session anymore
363+
session_write_close(); //we do not need to write access to session anymore
364364
if (!is_file($full_file_name)) {
365365
return false;
366366
}
@@ -383,7 +383,7 @@ public static function file_send_for_download(
383383
// Force the browser to save the file instead of opening it
384384
if (isset($sendFileHeaders) &&
385385
!empty($sendFileHeaders)) {
386-
header("X-Sendfile: $filename");
386+
header("X-Sendfile: $full_file_name");
387387
}
388388

389389
header('Content-type: application/octet-stream');

0 commit comments

Comments
 (0)