| Author |
|
Otomatic

Joined: 01 Sep 2011 Posts: 344 Location: Paris, France, EU
|
Posted: Thu 06 Aug '26 17:00 Post subject: 'Primary script unknown' into Apache logs |
|
|
Hi,
The Apache log files are (almost) entirely filled with lines like the one below, and they fill up very quickly.
| Code: | [Thu Aug 06 14:32:56.147608 2026] [proxy_fcgi:error] [pid 7240:tid 140597490640640] [client 20.52.171.102:33522] AH01071: Got error 'Primary script unknown'
[Thu Aug 06 14:32:56.213311 2026] [proxy_fcgi:error] [pid 7240:tid 140597616531200] [client 20.52.171.102:33522] AH01071: Got error 'Primary script unknown'
[Thu Aug 06 14:32:56.253052 2026] [proxy_fcgi:error] [pid 7240:tid 140597952239360] [client 20.52.171.102:33522] AH01071: Got error 'Primary script unknown'
[Thu Aug 06 14:32:56.285877 2026] [proxy_fcgi:error] [pid 7240:tid 140597868312320] [client 20.52.171.102:33522] AH01071: Got error 'Primary script unknown'
[Thu Aug 06 14:32:56.320068 2026] [proxy_fcgi:error] [pid 7311:tid 140597767599872] [client 20.52.171.102:32134] AH01071: Got error 'Primary script unknown'
|
My web host told me that this was caused by a bot and that it would be a good idea to add the following lines to an .htaccess file:
| Code: | <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^\s*$ [OR]
RewriteCond %{HTTP_USER_AGENT} "(?:Amazonbot|BLEXBot|Barkrowler|DataForSeoBot|MJ12bot|DotBot|AhrefsBot|SemrushBot|SeekportBot|CCBot|Baiduspider|Yandex|Sogou|PetalBot|Bytespider|OAI-SearchBot|GPTBot|ChatGPT-User|PerplexityBot|ClaudeBot)" [NC]
RewriteRule ^ - [R=429,L]
</IfModule> |
What do you think? |
|
| Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7481 Location: EU, Germany, Next to Hamburg
|
Posted: Fri 07 Aug '26 8:10 Post subject: |
|
|
It is a better solution to get a real 404 error. To do that you better check if that file exists.
| Code: |
<Files ~ "\.php$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</If>
</Files>
|
|
|
| Back to top |
|
Otomatic

Joined: 01 Sep 2011 Posts: 344 Location: Paris, France, EU
|
Posted: Fri 07 Aug '26 9:41 Post subject: |
|
|
Thank you.
However, if I add this to the .htaccess file on my local site, when I request access to the website, a window appears with the title:
Enter the file name for saving
And a file name like: IRbiKAYR |
|
| Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7481 Location: EU, Germany, Next to Hamburg
|
Posted: Fri 07 Aug '26 12:44 Post subject: |
|
|
| Pardon me for that. How was the Handler set before? Because now the file content is sent as a download. I'm pretty sure it contains the PHP code. |
|
| Back to top |
|
Otomatic

Joined: 01 Sep 2011 Posts: 344 Location: Paris, France, EU
|
Posted: Fri 07 Aug '26 15:13 Post subject: |
|
|
Hi,
The Handler is :
| Code: | | AddHandler application/x-httpd-php .php |
And, yes the saved file contains the PHP code. |
|
| Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7481 Location: EU, Germany, Next to Hamburg
|
Posted: Tue 11 Aug '26 9:09 Post subject: |
|
|
| I wonder. Where do you use proxy fcgi? |
|
| Back to top |
|
Otomatic

Joined: 01 Sep 2011 Posts: 344 Location: Paris, France, EU
|
Posted: Tue 11 Aug '26 10:03 Post subject: |
|
|
Hi,
I’m not entirely sure how things are configured with my hosting provider.
What I do know is that the mod_proxy_fcgi.c module is loaded and that the Apache configuration (2.4.43) contains directives such as:
| Code: | <Location /php-status-www>
SetHandler proxy:unix:/srv/run/php/www.sock|fcgi://localhost
</Location> |
Sorry, I can't say any more than that. |
|
| Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7481 Location: EU, Germany, Next to Hamburg
|
Posted: Thu 13 Aug '26 12:40 Post subject: |
|
|
First thought is to surround that with the "does the file exist" question.
| Code: |
<Location /php-status-www>
<If "-f %{REQUEST_FILENAME}">
SetHandler proxy:unix:/srv/run/php/www.sock|fcgi://localhost
</If>
</Location>
|
The other thought is: does it make sense to look for the requesting host and limit that. Like REMOTE_ADDR or REMOTE_HOST. Or require ip 10.1.0.0/16 or Require host example.org
See https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html#reqhost and https://httpd.apache.org/docs/2.4/expr.html |
|
| Back to top |
|