Proxy fcgi error primary script unknown

I got this error on apache logs: [Mon Oct 01 21:56:45.* 2018***] [proxy_fcgi:error] [pid 145*:*tid 14****] [client ****] AH01071: Got error 'Primary script unknownn' [Mon Oct 01 21:56:4*** 2018] [proxy_fcgi:error] [pid 14535:tid 140****] [client *****] AH01071: Got error 'Primary script...

  • #1

I got this error on apache logs:

Code:

[Mon Oct 01 21:56:45.* 2018***] [proxy_fcgi:error] [pid 145*:*tid 14****] [client ****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:4*** 2018] [proxy_fcgi:error] [pid 14535:tid 140****] [client *****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:45.916027 2018] [proxy_fcgi:error] [pid 145***:tid 140*****] [client *****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:46****2018] [proxy_fcgi:error] [pid 145***:tid 140*****2] [client ****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:4*** 2018] [proxy_fcgi:error] [pid 145**:tid 1401*****] [client ****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:47*2018] [**proxy_fcgi:error] [pid 14***:tid 140*****] [client ****] AH01071: Got error 'Primary script unknownn'
[Mon Oct 01 21:56:4* 2018] ***[proxy_fcgi:error] [pid 145***:tid 1401***] [client ********] AH01071: Got error 'Primary script unknownn'

Why im getting this error?
How to fix?

  • #2

I guess that means the php file does not exist (404), primary with bots/etc trying to find vulnerable scripts, but the htaccess is wrong.

See here

  • #3

I guess that means the php file does not exist (404), primary with bots/etc trying to find vulnerable scripts, but the htaccess is wrong.

See here

little confused, to which htaccess code should i use?

  • #4

@rtdirect,

I guess you need to check the link in the post #2 suggested by Peter, and you will probably understand what has it to do with .htaccess.

  • #5

@rtdirect,

I guess you need to check the link in the post #2 suggested by Peter, and you will probably understand what has it to do with .htaccess.

my htaccess code not like that.
there is no /fc2/ on me.

  • #6

Yeah but that htaccess code isnt same with mine.

  • #7

my htaccess code not like that.
there is no /fc2/ on me.

Try

  • #8

i appreciate with your help but my htaccess is similar to wordpress default htaccess.

Like this:

Code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

There are also some plugin added codes in it.

  • #9

I’m actually seeing this myself without even realising :(

No error pages appear to the browser, just a «File not found» appears for .php pages…….

Looks like it’s a deeper problem than I first thought.

Erm…. Apache and php-fpm.

  • #10

I have just noticed the same thing (never did before, no real reason to check for 404s errors :) )

I also found the solutions for both Nginx and Nginx+Apache
If you’re using only Nginx and php-fpm use this when you’re calling the PHP handler:

Code:

fastcgi_intercept_errors on;

(https://serverfault.com/questions/628810/serve-a-custom-404-page-generated-by-php)

If you’re using Nginx+Apache (or only Apache) and php-fpm use this when you’re calling the PHP handler:

(https://stackoverflow.com/questions/33843786/custom-404-message-when-using-php-fpm-with-apache=

Quick example for Apache:

Code:

                        ProxyErrorOverride on
                        AddHandler "proxy:unix:/usr/local/php56/sockets/cn.sock|fcgi://localhost" .php56

I think is more likely to be better to change the templates using custom versions, but probably much better if DA add this option as default.

I am going to forward the URL to this thread to John.

PLEASE NOTE: Enabling this option might disable the per-site custom error pages (as for instance the one generated by WP) in Nginx (it does NOT in Apache, I tested, but Apache uses .htaccess to override this, on Nginx there is no .htaccess so I am not sure how the custom error pages in WP do works and if this might cause an issue.
In Nginx I presum Custom HTTPD Templates will be used, so it still might be fine actually.

Regards

Last edited: Oct 11, 2018

  • #11

I wonder if this was an oversight, as, like Sellerone, I dont check errors etc….

  • #12

A fix for Apache has been addded, now in pre-release: https://www.directadmin.com/features.php?id=2211
For Nginx has not yet been implemented because John wasn’t able to replicate (as for Apache, but since there were 3 ppl having this issue did just make sense to fix it)

Regards

  • #13

A fix for Apache has been addded, now in pre-release: https://www.directadmin.com/features.php?id=2211
For Nginx has not yet been implemented because John wasn’t able to replicate (as for Apache, but since there were 3 ppl having this issue did just make sense to fix it)

You write «a fix for Apache», but the feature page says «nginx+apache», I sure hope it is not added for plain Apache.

I don’t know about Nginx and Nginx+Apache, but you must not add «ProxyErrorOverride on» for plain Apache, that will break Drupal «Maintenance Mode page», because Drupal is actually sending a HTTP status 503 for their Maintenance Mode page. It is also likely that this will cause trouble for other CMS.

  • #14

Apache doesn’t care if it’s the only webserver, the fix is on the check for PHP-FPM, regardless of Nginx, that’s why is a fix for Apache, it would work on any Apache related configuration when using PHP-FPM.

Wouldn’t Drupal use a .htaccess file to override the error pages?

  • #15

All I am saying is that DirectAdmin should not add «ProxyErrorOverride on» to /etc/httpd/conf/extra/httpd-default.conf for us that use plain Apache (I don’t know about Nginx and don’t use it). I have tested this because DirectAdmin added «ProxyErrorOverride on» in the beginning of march 2018, and I got support tickets from customers complaining that Drupal maintainance page did not work any more. I sent a ticket to DirectAdmin wich reverted this change in CustomBuild 2.0 rev. 1846. I have now sent a new ticket to DirectAdmin to let them know about this again.

Regarding Drupal and their «Maintenance Mode page», this thread might give some information about that: https://www.drupal.org/project/drupal/issues/2674900 (please note Drupal is not going to change this, because the status says «Closed (works as designed)».

  • #16

I see your point, but that’s not where has been added actually

Code:

Relates to not passing errors to nginx, and instead let php/apache generate the error pages.
The 4 virtual_host2*.conf files will have:
ProxyErrorOverride on

just before the AddHandler for both php1-fpm and php2-fpm.

I will check that Drupal report, do you have by any chance a test server where Drupal is configured and I can run some confs tests so to find a better solution if this doesn’t work?

  • #17

Drupal is actually responding with a 503 which is an HTTP Server code, so I don’t see the problem on using the HTTP Server to handle them.

Then, if you want to have a custom page that says «Mantainance mode on» that’s up to the customer and can (and should) be managed by .htaccess.

I don’t see nor understand how PHP would handle that better, I would need an example

  • #18

I found some example to have custom 503 Page on Drupal and not the server one (which I repeat, are the correct one to be showed for every normal case), sites have been using standard web server error page for ages, I don’t see how Drupal can have a «say» on that :)

https://groups.drupal.org/node/256708

https://gist.github.com/perusio/3778833

Custom code for the Nginx config:

Code:

error_page 503 = @503;

location @503 {
     if ($upstream_http_etag) {
         return 503 "Site down for maintenance. We'll be back shortly";
     }
}

Best regards

  • #19

@SeLLeRoNe, Well this is how Drupal handle Maintenance page, and we are a shared hosting and we need to support Drupal out of the box. The Drupal Maintenance page does not work when «ProxyErrorOverride on» is added, but instead show the default Apache 503 status page. As a shared host, we can’t tell customers to use different solutions, we need to support Drupal out of the box.

Again I ask that «ProxyErrorOverride on» is not added for us that use plain Apache. If it is added by DirectAdmin, we will remove it manually on every update. I am not going into a debate on this. I have said all I have to say.

  • #20

Is not matter of Apache or Nginx+Apache, that is not what is causing the problem, the problem is Apache+PHP-FPM and Nginx+PHP-FPM and Nginx+Aoache+PHP-FPM.

If you use Apache+MOD_PHP you would have the error pages handled by Apache aswell, even in that case you wouldn’t use the Drupal one unless you have custom .htaccess or customizations in Apache configuration.

That option is used when you are using a Proxy after Apache (as PHP-FPM work).
If Drupal is working as stand-alone application it would means you’re proxying it, so you wouldn’t put that option on that proxy coniguraiton, while DA is adding that for the specific AddHandler bit when PHP-FPM is in place, not as a default option.

Here an example of configuration from last update from my server:

Code:

                <FilesMatch ".(inc|php|phtml|phps|php72)$">
                        ProxyErrorOverride on
                        AddHandler "proxy:unix:/usr/local/php72/sockets/cn.sock|fcgi://localhost" .inc .php .phtml .php72
                </FilesMatch>
                <FilesMatch ".(inc|php|phtml|phps|php56)$">
                        ProxyErrorOverride on
                        AddHandler "proxy:unix:/usr/local/php56/sockets/cn.sock|fcgi://localhost" .php56
                </FilesMatch>

If you’re bypassing somehow PHP-FPM for Drupal (not sure, never used Drupal so mine are just hypotesis), than you should be fine.
If Drupal is working as any other PHP Application, which is run from PHP (either mod_php or PHP-FPM) than the result shouldn’t change with that option.

Again, the change is not in the default template as you wrote, so that shouldn’t even affect you.

Best regards

PabloC


  • #1

Hello,

I’ve these errors in my Apache log

[Sat Oct 05 17:05:05.220094 2019] [proxy_fcgi:error] [pid 8034:tid 47199407486720] [client 66.249.64.147:42456] AH01071: Got error ‘Primary script unknownn’
[Sat Oct 05 17:33:43.955785 2019] [proxy_fcgi:error] [pid 8035:tid 47199497000704] [client 52.192.73.251:28947] AH01071: Got error ‘Primary script unknownn’

Could anyone guide me about how to solve this?

Thanks!

  • #2

Hello,

I’ve these errors in my Apache log

[Sat Oct 05 17:05:05.220094 2019] [proxy_fcgi:error] [pid 8034:tid 47199407486720] [client 66.249.64.147:42456] AH01071: Got error ‘Primary script unknownn’
[Sat Oct 05 17:33:43.955785 2019] [proxy_fcgi:error] [pid 8035:tid 47199497000704] [client 52.192.73.251:28947] AH01071: Got error ‘Primary script unknownn’

Could anyone guide me about how to solve this?

Thanks!

Post server details to help guide you better.
Apache version, C-panel and others

PabloC


  • #3

Apache 2.4.41
PHP 7.2.23
cPanel 82.0 (build 16)
MariaDB 10.1.41

Is this enough? pls let me know.

thanks!

cPanelLauren


  • #4

Hello,

What (if anything) is noted in the PHP-FPM error logs? You can find them per PHP version at /opt/cpanel/ea-phpXX/root/usr/var/log/php-fpm/error.log

Do you have any rewrite rules added in the .htaccess for the sites you’re seeing this occur with (if you’re able to pin it down to a specific site)

PabloC


  • #5

Hello!

I’ve got hundreads of lines like this

[08-Oct-2019 19:08:55] NOTICE: [pool todoperros_com] child 18693 started
[08-Oct-2019 19:08:59] NOTICE: [pool todoperros_com] child 18665 exited with code 0 after 62.181765 seconds from start
[08-Oct-2019 19:08:59] NOTICE: [pool todoperros_com] child 18695 started
[08-Oct-2019 19:09:28] NOTICE: [pool todoperros_com] child 18682 exited with code 0 after 58.940302 seconds from start
[08-Oct-2019 19:09:28] NOTICE: [pool todoperros_com] child 18744 started
[08-Oct-2019 19:09:45] NOTICE: [pool todoperros_com] child 18689 exited with code 0 after 57.722906 seconds from start
[08-Oct-2019 19:09:45] NOTICE: [pool todoperros_com] child 18757 started
[08-Oct-2019 19:09:55] NOTICE: [pool todoperros_com] child 18692 exited with code 0 after 60.578018 seconds from start
[08-Oct-2019 19:09:55] NOTICE: [pool todoperros_com] child 18762 started
[08-Oct-2019 19:10:00] NOTICE: [pool todoperros_com] child 18695 exited with code 0 after 61.794768 seconds from start
[08-Oct-2019 19:10:00] NOTICE: [pool todoperros_com] child 18764 started
[08-Oct-2019 19:10:00] NOTICE: [pool todoperros_com] child 18693 exited with code 0 after 65.109071 seconds from start
[08-Oct-2019 19:10:00] NOTICE: [pool todoperros_com] child 18765 started
[08-Oct-2019 19:10:28] NOTICE: [pool todoperros_com] child 18744 exited with code 0 after 60.538661 seconds from start
[08-Oct-2019 19:10:28] NOTICE: [pool todoperros_com] child 18883 started
[08-Oct-2019 19:10:45] NOTICE: [pool todoperros_com] child 18757 exited with code 0 after 60.214805 seconds from start
[08-Oct-2019 19:10:45] NOTICE: [pool todoperros_com] child 18926 started
[08-Oct-2019 19:10:57] NOTICE: [pool todoperros_com] child 18762 exited with code 0 after 61.690406 seconds from start
[08-Oct-2019 19:10:57] NOTICE: [pool todoperros_com] child 18937 started
[08-Oct-2019 19:11:01] NOTICE: [pool todogatos_com] child 18797 exited with code 0 after 47.239572 seconds from start
[08-Oct-2019 19:11:01] NOTICE: [pool todogatos_com] child 18945 started
[08-Oct-2019 19:11:06] NOTICE: [pool todoperros_com] child 18764 exited with code 0 after 65.841152 seconds from start
[08-Oct-2019 19:11:06] NOTICE: [pool todoperros_com] child 18947 started
[08-Oct-2019 19:11:06] NOTICE: [pool todoperros_com] child 18765 exited with code 0 after 65.844983 seconds from start
[08-Oct-2019 19:11:06] NOTICE: [pool todoperros_com] child 18948 started

Yes, I have many rewrite rules in my main site.

What could be causing this? any ideas?

Thanks for your help! I don’t know what is going on…

cPanelLauren


  • #6

Those are just notices, this issue is commonly attributed to script errors or rewrite rules, you may need to go through the rewrite rules thoroughly to pinpoint the problem.

  • #7

I’ve just started seeing these errors, I guess since enabling FPM.
I don’t see anything which gives away the cause in the fpm error.log.

Any pointers ?

Здравствуйте, господа. Имеется связка Nginx + PHP7-FPM. При попытке открыть несуществующий файл test.php
(example.com/test.php) получаю в браузере сообщение «File not found». При этом в /var/log/nginx/error.log появляется следующее:

2018/01/16 21:53:04 [error] 10214#10214: *21 FastCGI sent in stderr: «Primary script unknown» while reading response header from upstream, client: 192.168.0.104, server: example.com, request: «GET /test.php HTTP/1.1», upstream:
«fastcgi://unix:/var/run/php/php7.0-fpm_example.com.sock:», host: «example.com»

При этом существующие php-файлы открываются исправно, без вывода чего-либо в /var/log/nginx/error.log.

В чём может быть дело? Предполагалось, что при обращении к несуществующему php-файлу (как и к любому другому несуществующему файлу), Nginx выдаст в браузере ошибку 404, а в /var/log/nginx/error.log будет записано сообщение об отсутствии запрашиваемого файла вроде этого:

2018/01/16 22:20:03 [error] 10642#10642: *11 open() «/home/example.com/www/test.php» failed (2: No such file or directory), client: 192.168.0.104, server: example.com, request: «GET /test.php HTTP/1.1», host: «example.com»

Ниже прилагаю конфиг /etc/nginx/sites-available/example.com.conf:

server {
    server_name             example.com;
    root                    /home/example.com/www;
    listen                  80;
    access_log              /var/log/nginx/access.log;
    error_log               /var/log/nginx/error.log error;

    location ~ .php$ {
        fastcgi_param SERVER_SIGNATURE      nginx;
        fastcgi_param SERVER_SOFTWARE       nginx;
        fastcgi_param SERVER_NAME           $server_name;
        fastcgi_param SERVER_ADDR           $server_addr;
        fastcgi_param SERVER_PORT           $server_port;
        fastcgi_param SERVER_PROTOCOL       $server_protocol;
        fastcgi_param SERVER_ADMIN          admin@$server_name;
        fastcgi_param HTTPS                 $https if_not_empty;
        fastcgi_param GATEWAY_INTERFACE     CGI/1.1;
        fastcgi_param DOCUMENT_ROOT         $document_root/;
        fastcgi_param DOCUMENT_URI          $document_uri;
        fastcgi_param QUERY_STRING          $query_string;
        fastcgi_param SCRIPT_FILENAME       $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME           $fastcgi_script_name;
        fastcgi_param REDIRECT_STATUS       200;
        fastcgi_param REDIRECT_QUERY_STRING $query_string;
        fastcgi_param REDIRECT_URL          $request_uri;
        fastcgi_param REQUEST_URI           $request_uri;
        fastcgi_param REQUEST_METHOD        $request_method;
        fastcgi_param REMOTE_ADDR           $remote_addr;
        fastcgi_param REMOTE_PORT           $remote_port;
        fastcgi_param REMOTE_USER           $remote_user;
        fastcgi_param CONTENT_TYPE          $content_type;
        fastcgi_param CONTENT_LENGTH        $content_length;
        fastcgi_index                       index.php;
        fastcgi_pass                        unix:/var/run/php/php7.0-fpm_example.com.sock;
    }
}

I encountered this error yesterday after upgraded php-* packages then restart its service. All my websites were stopped working, I got ‘File not found.’ message on the screen and found the ton repeated of error messages in log of nginx Primary script unknown.

How to fix nginx Primary script unknown or file not found

Nginx/PHP-FPM: How to fix ‘Primary script unknown’ or ‘file not found’ issue

TL;DR:

  • Since php-fpm version 7.4.0 php-fpm.service defines ProtectHome=true which restricts access to files located within /home, /root and /run/user, yielding the error message No input file specified.
  • To fix this problem, either set ProtectHome=false in php-fpm.service file or move your document root.

The issue I’m facing after fully upgraded system, reboot my VPS:

  • Browsing to it in browser returns the text “File not found”.
  • nginx error.log contains:

    2019/12/17 15:36:09 [error] 1502#1502: *1 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, …

The message is telling us that the FastCGI handler doesn’t like whatever it was sent for some reason. The problem is that sometimes we have no idea what the reason is. On my experience of using nginx, the error message Primary script unknown is almost always related to a wrongly set SCRIPT_FILENAME in the nginx fastcgi_param directive or incorrect permissions. It’s seem correctly answer when the php-fpm.service stopped working with error:

ERROR: failed to open configuration file ‘/etc/php/php-fpm.conf’: Permission denied (13)

I tried turns out that the root location had to match the location of the files on the php-fpm as that’s what was being past through via:

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name

But it doesn’t work.
Well, if I remove my SCRIPT_FILENAME then all I get is an empty, white, blank page by nginx. No error messages either. It’s mean fastcgi_param is not cause of this problem.
If the SCRIPT_FILENAME is wrong, it may also be PHP is running as the wrong user/group. I take a look on php-fpm.conf, php-fpm.d/www.conf and double-checked for errors and inconsistencies. Everything is ok , no conflicted.
Just wait, I stored all LEMP’s config files in a folder then created symlinks of them to /etc/nginx/ and /etc/php folders. Everything was working fine before I upgraded php-fpm to version 7.4.0. After that, the PHP service only started when all the symbolic links were replaced by real files. Furthermore, my website has ‘file not found‘ error, it’s meaning the files on server is inaccessible. They were isolated.
So I’m seem to figure out what is causing this. It’s PHP-FPM service. It has ProtectHome set to true since 7.4.0!
This problem was caused by ProtectHome=true in the php-fpm systemd unit file if you are serving files in /home such as in a virtual host environment. You can disable this feature by editing the php-fpm unit file and restarting php-fpm.

# systemctl edit php-fpm

Looking for ProtectHome=true then change it to false or add the following:

[Service]
ProtectHome=false

Alternatively, move your document root.
If you are not sure about the ProtectHome is existed, here is the command to check it is running:

$ sudo systemctl cat php-fpm.service | grep ProtectHome   
ProtectHome=true

Before restart php-fpm service, make sure to reload the systemd daemon:

$ sudo systemctl daemon-reload

It’s done. Everything is OK now.

What is ProtectHome?

Takes a boolean argument or the special values “read-only” or “tmpfs“.

  • If true, the directories /home, /root, and /run/user are made inaccessible and empty for processes invoked by this unit.
  • If set to “read-only“, the three directories are made read-only instead.
  • If set to “tmpfs“, temporary file systems are mounted on the three directories in read-only mode. The value “tmpfs” is useful to hide home directories not relevant to the processes invoked by the unit, while still allowing necessary directories to be made visible when listed in BindPaths= or BindReadOnlyPaths=.

Setting this to “yes” is mostly equivalent to set the three directories in InaccessiblePaths=. Similarly, “read-only” is mostly equivalent to ReadOnlyPaths=, and “tmpfs” is mostly equivalent to TemporaryFileSystem= with “:ro“.
It is recommended to enable this setting for all long-running services (in particular network-facing ones), to ensure they cannot get access to private user data, unless the services actually require access to the user’s private data. This setting is implied if DynamicUser= is set. This setting cannot ensure protection in all cases. In general it has the same limitations as ReadOnlyPaths=.
This option is only available for system services and is not supported for services running in per-user instances of the service manager.

Понравилась статья? Поделить с друзьями:
  • Provider named pipes provider error 40 не удалось открыть подключение к sql server
  • Proxy error the proxy server received an invalid response from an upstream server
  • Proxy error host is down i2p
  • Provider named pipes provider error 40 visual studio
  • Protherm jaguar jtv 24 ошибка f08