Error: 504 Gateway Timeout after 60 seconds.

We are trying to run a PHP script that takes 300 seconds to execute.
After exactly 60 seconds, the connection is closed with an error: 504 Gateway Timeout.
However, the script continues to run in the background and finishes its task successfully after 300 seconds - the script is not being killed (that's OK!).


Fetching the actual output from the endpoint is impossible because the connection is closed faster than it needs for execution.

What steps should be taken to increase the 60 seconds timeout limit to 300 seconds?

Actions taken (didn't work):
#1) .htaccess
RewriteEngine On
RewriteRule .* - [E=noabort:1, E=noconntimeout:1]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

#2) Manual configuration
Server Configuration > Tuning > Connection Timeout (secs) = 300

#3) Service restart
systemctl restart lsws

PHP 8.0.25
LiteSpeed/1.7.16 Open (BUILD built: Mon Oct 17 21:33:28 UTC 2022)
module versions:
lsquic 3.1.1
modgzip 1.1
cache 1.64
mod_security 1.4

Best regards and I would be grateful for any suggestions