0

When I try to access

  • domain.com/status/show or
  • domain.com/status/ping,

I get following error in nginx:

2024/08/24 19:36:11 [error] 7448#0: *13203 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 15.16.2.54, server: domain.com, request: "GET /status/show HTTP/1.1", upstream: "fastcgi://unix:/usr/local/php74/sockets/domain.com:", host: "domain.com"

I am using same configurations on other server and it works without any problems. The only difference is there PHP version is PHP 8.2.

On this server with PHP 7.4 this same config does not work for some reason.

I tired lot of things, but nothing works and I am out of ideas.

Note I especially checked if status page exists prior PHP 8.0 and it exists from PHP 5.3.

My php-fpm config file is:

[domain.com]

user  = www
group = www

listen = sockets/domain.com


listen.owner = www
listen.group = www
listen.mode = 0660

include = etc/common.conf

;access.format is in common
access.log = var/log/$pool.access.log

; The log file for slow requests
slowlog = var/log/$pool.slow.log

; The timeout for serving a single request after which a PHP backtrace will be
request_slowlog_timeout = 10s

common.conf

; Note: This value is mandatory.
pm = dynamic

pm.max_children  = 800

;pm.start_servers = 8
pm.min_spare_servers = 16
pm.max_spare_servers = 32

pm.process_idle_timeout = 90s;

; The number of requests each child process should execute before respawning.
pm.max_requests = 10000

pm.status_path = /status/show

ping.path = /status/ping

access.format = "\"%R\" - %{REMOTE_ADDR}e - %{HTTP_CF_CONNECTING_IP}e - %u [%t] \"%m %r%Q%q\" \"%{REQUEST_URI}e\" %s %l %M %d"

nginx host

server {
    listen      80;
    listen      443 ssl http2;

    server_name domain.com  www.domain.com;

    root        /www/sites/domain.com;

    location ~ ^/index\.php(/|$) {
        fastcgi_pass            unix:/usr/local/php74/sockets/domain.com;

        fastcgi_split_path_info     ^(.+\.php)(/.*)$;

        include             fastcgi.conf;

        fastcgi_param           SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param           PATH_INFO   $fastcgi_path_info;

        internal;
    }

    location ~ .\.php(/|$) {
        fastcgi_pass            unix:/usr/local/php74/sockets/domain.com;

        fastcgi_split_path_info     ^(.+\.php)(/.*)$;

        include             fastcgi.conf;

        fastcgi_param           SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param           PATH_INFO   $fastcgi_path_info;
    }

    location ~* ^/status/(show|ping)(/|$) {
        fastcgi_pass            unix:/usr/local/php74/sockets/domain.com;

        include             fastcgi.conf;

        fastcgi_param           SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    }

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

fastcgi.conf

fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;

#fastcgi_param  SCRIPT_FILENAME     $document_root$fastcgi_script_name;
#fastcgi_param  SCRIPT_NAME     $fastcgi_script_name;

fastcgi_param   PATH_INFO       $fastcgi_path_info;
fastcgi_param   PATH_TRANSLATED     $document_root$fastcgi_path_info;

fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   DOCUMENT_URI        $document_uri;
fastcgi_param   DOCUMENT_ROOT       $document_root;
fastcgi_param   SERVER_PROTOCOL     $server_protocol;
fastcgi_param   REQUEST_SCHEME      $scheme;

#fastcgi_param  HTTPS           $https;

fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE     nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_NAME     $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;
3
  • The script name /www/sites/domain.com/status/show is not found. It probably needs to end with .php. You could try adding to the location block: try_files $uri.php =404; Commented Aug 25, 2024 at 8:18
  • no, this is fpm's internal status URL Commented Aug 26, 2024 at 8:32
  • Correct. "Primary script unknown" in stderr is almost always because SCRIPT_FILENAME does no contain the correct pathname of the script. I can see that your config is setting it to /www/sites/domain.com/status/show, whereas it should probably be set to /www/sites/domain.com/status/show.php. You need to change the value of $fastcgi_script_name from /status/show to /status/show.php, which can be achieved using a rewrite...break or try_files. Or even just appending .php to the end of the fastcgi_param SCRIPT_FILENAME value. Commented Aug 26, 2024 at 18:51

1 Answer 1

0

It turns out, the configuration did not set following param:

fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;

Once I added it it worked normally.

Interesting this broke just this URL /status/show and nothing else.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.