'How to Debug a Generic 500 Server Error "FastCGI" sent in stderr: "Primary script unknown" while reading response header and alot of unknown requests

I am a total newbie into deployment and managing servers so I got this error I read a lot of articles but it doesn't work for me

this is my Nginx config file:

server {
    listen 80;
    listen [::]:80;
    server_name IP;
    root /var/www/backend/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }


        location ~ /\.(?!well-known).* {
                deny all;
        }

}

What I got is always the POST request gets 500, GET is 200 and working I don't get it

- - [23/Mar/2022:09:33:19 +0000] "POST /api/product HTTP/1.1" 500 44 "-" "PostmanRuntime/7.29.0"
- - [23/Mar/2022:09:08:09 +0000] "GET /api/product HTTP/1.1" 200 496 "-" "PostmanRuntime/7.29.0"
- - [23/Mar/2022:09:08:14 +0000] "GET /api/product HTTP/1.1" 200 496 "-" "PostmanRuntime/7.29.0"
- - [23/Mar/2022:09:08:15 +0000] "GET /api/product HTTP/1.1" 200 496 "-" "PostmanRuntime/7.29.0"
- - [23/Mar/2022:09:08:17 +0000] "GET /api/product HTTP/1.1" 200 496 "-" "PostmanRuntime/7.29.0"

I GOT A TRACE FILE by attaching the PID but still can't see the error :(

I am sorry for being all over the place and thanks in advance :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source