I have an Angular webapp running with a PHP backend. Further I’m using SLIM as the webserver and this worked fine for several years. In the SLIM webserver is a simple file cache integrated.
Suddenly I receive upstream prematurely closed connection while reading response header from upstream
as soon as the file cache is activated. I was able to find the line in code that causes the error. It is the point where I call file_put_contents
. But I don’t understand why? What is going wrong and how can I fix it?
I already tried to find a solution and tried several approaches found to modify my nginx.conf
. But nothing worked!
Please does anybody has a solution!
nginx.conf
#nginx
proxy_buffering off;
#fastcgi
fastcgi_buffering off;
# serve any request starting with `/rest` with the following location
location ~ /rest {
try_files $uri $uri/ /rest/index.php$is_args$args;
location ~ .php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_send_timeout 3600s;
fastcgi_read_timeout 3600s;
}
}
# serve all the other requests with the Angular app
location ~ / {
proxy_pass http://127.0.0.1:4000;
}
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Expose-Headers Content-Length;
add_header Access-Control-Allow-Headers Range;
add_header X-Frame-Options "SAMEORIGIN";