admin管理员组文章数量:1397065
I have a server ruled by Plesk running on Apache 2.4.41 and Nginx used in proxy mode.
I also have ModSecurity enabled with Comodo rules (free). I use PHP 7.4.3 (FPM served by Apache) for back-end scripts with output buffering in my "php.ini" file set as follows output_buffering = 8192
.
I'm trying to flush data as soon as they're "echo"ed but everything I tried failed so long.
I have already checked this topic and it didn't help.
I've created the following script for testing purpose:
ob_start();
$respond = function() {
while(ob_get_level()) ob_end_flush();flush();
};
echo "1\n";
$respond();sleep(2);
echo "2\n";
$respond();sleep(2);
echo "3\n";
$respond();sleep(2);
When I run the above script, it waits for the script to complete before outputting the result.
I have tried to set specific directives for Nginx related to my script as follows
location = /path/to/my/script.php {
proxy_buffering off;
proxy_request_buffering off;
chunked_transfer_encoding on;
fastcgi_request_buffering off;
fastcgi_buffering off;
tcp_nodelay on;
}
I have also added special directives for Apache like so
<Location /path/to/my/script.php>
SetEnv no-gzip 1
SetEnv dontlog 1
SetEnv proxy-nokeepalive 1
</Location>
I tried with PHP the following:
ini_set('output_buffering', '0');
ini_set('zlib.output_compression', '0');
ob_implicit_flush(true);
I've checked using a terminal to execute a similar script with PHP-Cli and it was being displayed every time it was "echo"ed so the problem is not at PHP level.
How to disable buffering in this case to allow data streaming?
One additional note, I don't want to disable buffering for my whole server but only for a specif script. The script is not accessible via a URL but used internally by the application. By the way, I don't mind if buffering is disabled for the URL using that script if no other solution exists.
本文标签: phpDisable output buffering for Apache with Nginx in proxy modeStack Overflow
版权声明:本文标题:php - Disable output buffering for Apache with Nginx in proxy mode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744104532a2591004.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论