0

I'm running Nginx with PHP-FPM with a very common configuration, nothing special:

        location / {
            try_files $uri @fpm;
        }

        location @fpm {
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_pass fpm:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /var/www/html/app/public/index.php;
            fastcgi_param SCRIPT_NAME index.php;
            fastcgi_param APPLICATION_ENV dev;
        }

The PHP-FPM is run in a container with a default PHP-FPM configuration (version 7.3 currently).

I found that if PHP script crashes unexpectedly without returning any response or when I debug a script with XDebug and stop debugging killing the request (not resume running until the end), Nginx returns the successful HTTP response code (200) with an empty response. How to make it returning an error code of the 5xx range in such cases? Probably, the problem could be in PHP-FPM returning a successful result but I didn't find any possible solutions for that.

  • Do you have any exaple?? What if you call a php script with something ivalid? Like a missing semicolon at the end? ``? Whats the current error level in your php.ini? That could be an issue. – Timo Stark Mar 31 '21 at 10:04
  • Scripts are working fine when everything goes normally. Typically, the issue happens when I stop debugging before any content emitted. What exact example do you expect? Of how to run Nginx + PHP-FPM + XDebug? Just run in any working configuration and then stop debugging killing the request (not continue running) and you'll get an empty response with HTTP 200 code. –  Apr 01 '21 at 00:47
  • Also, I mentioned a crash, when the PHP worker process just dies, not an execution stopped by an exception or a parsing error. The error level doesn't make any sense in this situation. I suppose the issue can be somewhere on the FPM side. –  Apr 01 '21 at 00:55

0 Answers0